Saturday 29 April 2017

Lecture#2 ka Point#75 (Csharp Roman Hindi/Urdu Me).

FUNCTION(BASIC MEMBER OF CLASS):

Function is a set of instructions. Program likhtey waqt kuch cheezey aesi hoti hain jinhey hum bar bar repeat kr rhey hotey hain to woh set of instructions jinhey hum bar bar repeat kr rhey hotey hain unhey hum function me convert kr letey hain.



Function bnaney ka maqsad code ko re-use krna hai.



Humara function alag hota hai aur humara program alag hota hai. Hum function ko apne program me call krtey hain. Humare program ka control jump kr jata hai us function pe jisey humney apne program me call krwaya hai aur woh pura function execute hota hai aur function execution jb khattum hoti hai to control wapis transfer ho jata hai program ki us line k very next jahan humney woh function call krwaya hoga.



Function ka koi "access modifier" hoga, koi "name" hoga aur kuch "attributes" & "properties" hongi. Function ko hum Sub-routine ya method ya procedure bhi kehtey hain.



Aik function woh hai jo aap se kuch input le aur us input ko process krne k baad kuch value return kre. Aik function woh hai jo koi value return nahi krta. Jo function value return kre ga hum us k sath uski return data type bhi mention kre ge.


FOR EXAMPLE: Public long Add(int i, int j){ return i+j; }



Jo function value return nahi krta us k sath hum void ka keyword likhtey hain. void ka matlab hota hai "no return data type".
FOR EXAMPLE: Public void Print(){ Console.WriteLine("Muhammad Shumail Cheema"); }



Jo variable hum function k scope ya "curly brackets{}" k ander likhen ge woh humara "local variable" kehlaye ga. "Local variable" ka scope function se bahir nahi hoga.



"Local variables" apni data type ki default value se initialize nahi hotey. Sirf "instance variables" apni data type ki default value se initialize hotey hain.

No comments:

Post a Comment