Can I give default value to parameters or optional parameters in C# functions?
<p>Can I give default parameters for C#?</p>

<p>in C</p>

<pre><code>  void fun(int i=1)
 {
   printf("%d",i);
 }
</code></pre>

<p>We can give parameters default value? Is it possible in C#. If so, can we avoid overloading functions? Thanks in Advance </p>

<p><strong>EDIT</strong></p>

<p>Its always a bad practice to add an optional parameter to an existing function. If you are working in a project which is having refer the class having a function and we changed a parameter with an optional value, it may throws run time exception that the method is not found.</p>

<p>this is because we will consider that the if we add an extra optional value, there is no code change required if the function is using in many places.</p>

<p><code>function Add(int a,int b);</code> 
this will called using this way 
<code>Add(10,10);</code> </p>

<p>but if we add an optional param like this, 
<code>function Add(int a,int b,int c=0);</code>
 then the compiler expects
<code>Add(10,10,0);</code>. </p>

<p>Actually we are calling like this <code>Add(10,10)</code> and this function won't be available in that class and causes a run time exception. </p>

<p>This happens for while adding a new param to a function which called by a lot of places and I not sure this will happen every time. But I suggest you to overload the function.</p>

<p>Always we need to overload the method which has an optional param. Also if you are working with functions having more than one optional parameter , then its good to pass the value using the name of the parameter.</p>

<p><code>function Add(int a,int b,int c=0);</code>
Its always good to call this function using the following way.
<code>Add(10,20,c:30);</code></p>
