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
Guest User
Tech Writer
357
120.8k
Why doesnt this method call work?
Aug 19 2012 2:50 PM
Hi
I have the following code example:-
class Program
{
static void Sum(params int[] ints)
{
int sum = 0;
for (int i = 0; i < ints.Length; i++)
{
sum += ints[i];
}
}
static void Main()
{
int[] ints = { 1, 2, 3, 4 };
Sum(ints);
Console.WriteLine(ints);
Console.ReadLine();
}
}
I was expecting the calling method "Main" to reflect the changes in the called method "Sum" as the array of ints is passed by reference?
Regards
Steven
Reply
Answers (
2
)
How to use Progress Bar in c# ?
Adding Column in gridview and bind