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
326k
for instead of foreach
Feb 18 2012 4:39 PM
Q(10) of the chapter
I wish to know in this program whether it is possible to use FOR instead FOREACH.
using System;
namespace _6e10
{
class Program
{
static void Main(string[] args)
{
int one = 1, three = 3, five = 5;
int[] num = new int[10] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; //Total 55
sum(one);
sum(three);
sum(five);
sum(num);
Console.ReadKey();
}
static void sum(params int[] integer)
{
int total = 0;
foreach (int number in integer)
{
total = total + number;
}
Console.WriteLine("Total {0}", total);
}
}
}
Attachment:
chapter6-exercises.zip
Reply
Answers (
3
)
Connect to an ip camera (AVTECH)
Constructor & get & set method