• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

Function Overloading in C# .Net

Function Overloading

Function overloading is a concept of writing more than one function  with same name and with different types of arguments.

 

Observations

Proto typepossible to overload
Public void Print ()1 & 2  Not possible
Private Void Print ()1 & 3 Not possible
Public int Print () 1& 4 Yes
Public void Print (Int x) 4 & 5 NO
Public void Print (int y) 4 & 6   Yes 
Public void Print (ref int x)4 & 7  Yes
Public Void Print  (out int x) 6 & 7 No
Public void Print  () 1 &8  Yes [Not overloading concept]

 

Example on function overloading

Open Window forms Application Project

Place a Button

Code in GD

 

Class Test

{

Public void print  ( float x)

{

Message . Box. Show  (“From float :”  + X);

}

Public void Print  (double X)

{

Message . Box. Show  (“From double:”  + X);

}

Public void Print  (decimal X)

{

Message . Box. Show  (“From decimal:”  + X);

}

}//test

 

Code for button1_click

 

Test t = new Test ();

 

  1. Print (4.0) ;//

//t. Print (4); error

  1. Print (4f);//float
  2. Print (4m);//decimal
  3. Print (4d);//double

 

 

 

 

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on Function Overloading in C# .Net"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Site Disclaimer, Copyright © 2016 - All Rights Reserved.

    Support


    Please leave a message and we'll get back to you soon.

    I agree to be contacted via e-mail.