TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Maha
NA
0
328.3k
foreach insted of for
Dec 10 2011 1:37 PM
I wish to whether it is possible to modify this program by using foreach instead for loop
using System;
public class ParallelArrays
{
public static void Main()
{
int[] validValues = { 101, 108, 201, 213, 266, 304, 311, 409, 411, 412 };
double[] prices = { 0.89, 1.23, 3.50, 0.69, 5.79, 3.19, 0.99, 0.89, 1.26, 8.00 };
//parallel array
int itemOrdered = 311;
for (int i = 0; i < validValues.Length; ++i)
{
if (itemOrdered == validValues[i]) //order doesn't matter
{
Console.WriteLine(prices[i]);
}
}
Console.ReadKey();
}
}
/*
0.99
*/
Reply
Answers (
4
)
c#
rabin krap algorithm by using rolling hash function in c #