Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 29th, 2004, 02:42 PM
Authorized User
Join Date: Aug 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default i need to understand this wrox code

LOOk :
using System;
namespace Wrox.ProCSharp.ParameterTestSample
class ParameterTest
static void SomeFunction(int[] ints, int i)
ints[0] = 100;
i = 100;
public static int Main()
int i = 0;
int[] ints = { 0, 1, 2, 4, 8 };
// Display the original values
Console.WriteLine(“i = “ + i);

Console.WriteLine(“ints[0] = “ + ints[0]);
Console.WriteLine(“Calling SomeFunction...”);
// After this method returns, ints will be changed,
// but i will not
SomeFunction(ints, i);
Console.WriteLine(“i = “ + i);
Console.WriteLine(“ints[0] = “ + ints[0]);
return 0;

i need to understand the bold

Old October 29th, 2004, 02:54 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts

You need to declare the parameters in the function with ref. That's why nothing changes; they are being passed as a value, so the original doesn't change.

Old October 31st, 2004, 12:07 PM
Friend of Wrox
Join Date: Feb 2004
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts

No the array is passed by reference so the value will change and the int is passed by value so it won't change.

It all depends on whether the passing variable type is "Value" or "Ref", for more info look at the following link


It is not how much we do,
but how much love we put in the doing.

-Mother Theresa

Similar Threads
Thread Thread Starter Forum Replies Last Post
understand a piece of code in assembler rbulus BOOK: Professional Assembly Language 1 January 10th, 2010 07:45 AM
C# Wrox CMS Code jminatel BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 5 June 3rd, 2009 04:41 AM
Trying to understand this line of code chriscym XSLT 2 April 17th, 2007 10:48 PM
can't understand this code I downloaded am6019a VB How-To 1 July 7th, 2006 09:11 AM
Can someone help me understand Quake III's code PaRaDoX C++ Programming 2 March 23rd, 2005 08:09 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.