Optional Parameters C# with Example



Optional Parameters C# with Example

 	using System;

	namespace CSharpFundamentals
	{
		class OptionalParameters
		{
			private static void Main(string[] args)
			{
				Console.WriteLine("Method Invoke Without Parameters: {0}", Addition());
				Console.WriteLine("Method Invoke With 1 Parameters {0}", Addition(10));
				Console.WriteLine("Method Invoke With 2 Parameters {0}", Addition(10, 20));
				Console.WriteLine("Method Invoke With 3 Parameters {0}", Addition(10, 20, 30));
			}

			static int Addition(int x = 0, int y = 0, int z = 0)
			{
				return x+y+z;
			}			
		}
	}
 

0 Comment's

Comment Form

Submit Comment