Parameter Array As Value C# with Example



Parameter Array As Value C# with Example

 	using System;

	namespace CSharpFundamentals
	{
		class ParameterArrayAsValue
		{
			private static void Main(string[] args)
			{
				int [] valArray = { 10, 20 };
				
				Console.WriteLine("Before Method Call: val1: {0} \t val2: {1}",valArray[0], valArray[1]);
				
				AddList(valArray);
				
				Console.WriteLine("After Method Call: val1: {0} \t val2: {1}",valArray[0], valArray[1]);
			}

			static void AddList(int[] intVals)
			{
				int [] newArray = {12, 32, 44};
				intVals = newArray;
			}
		}
	}
 

0 Comment's

Comment Form

Submit Comment