Monday 11 January 2016

Name and Optional parameters, C#, simple example.


Named and Optional Parameters (Syntax)
Calling or telling somebody, is something very important, it turns the fate, it lets somebody achieve what he wants.
The fate of code is also based on it, immensely. The piece of code should be callable. 
If we define or create something, putting all the hard work of the world, but no body could use it, even you could not use it, then no other painful situation is better than this.
When we call callable code, we sometimes, add extra information to it, for example, we call Mohit but we may call him telling to come to such and such place. We can call Mohit to come and come to a particular place like Cicely. This extra information is called Parameters in terms of code. 

In C# this is a syntax of callable function without special argumest or parameters like named and optional:

namespace SuperDemo{ 
 class Demo{
     public void Save(string name, short age, string address)
    {
     // code
   } 
}
}

Named and Optional Parameters

namespace SuperDemo{ 
 class Demo{
     public void Save(string name, short age=25, string address="default address")
    {
     // code
   } 
}
}


Thanks and keep hardworking !!!

Ashumeet Mitter


No comments:

Post a Comment