Saturday 22 July 2017

Lecture#3 ka Point#80 (Csharp Roman Hindi/Urdu Me).

Agar 2 functions same name k same class me hain lakin in k signatures different hain to isey hum function overloading ya method overloading kehtey hain. Function overloading ka taluq uski implementation, access modifier, return data type se nahi hoga balkey function overloading ka taluq us k naam aur signature se hoga. Agar function ka naam same hoga aur signature different hoga tb function overloading hogi. Function signature me arrangement of arguments ka matlab yeh hai k arguments ki data type ka arrangement change kr den.





Agar aik naam k two functions hain aur in dono functions k signature ka arrangement change hai.


FOR EXAMPLE:

Public long Add(int i, short j){......}            //first function


Public long Add(short i, int j){......}            //second function



Jab hum class se bahr in dono me se kisi aik function ko call kerwaye ge to is function k kisi aik argument k saath us ki type casting kre ge jis se identify hoga k hum kon sa function call krwa rhey hain. Agar hum type casting nahi kre ge to compile-time error aa jaye ga.


FOR EXAMPLE:

obj.Add(1, (short)1);            //call first function



Agar function ko call krwatey waqt function me koi parameter number without type casting pass krwaye ge to woh by-default integer hoga.


FOR EXAMPLE:

Public long Add(int i, int j){......}                 //first function



Public long Add(int i, short j){......}            //second function


obj.Add(1, 1);                                              //call first function


obj.Add(1, (short)1);                                  //call first function

No comments:

Post a Comment