Monday 24 July 2017

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

Class k instance variable ko jab declare krte hain to woh khud hi apni data type ki default value se initialize ho jata hai aur is instance variable ko is ki data type ki default value se is class ka default constructor ya constructor initialize krwata hai. Humey class k instance variables ki koi khud se value set krwani ho to usey hum constructor me initialize kre ge aur jesey hi humari class ka object initialize hoga to constructor call ho jaye ga aur instance variable ki value set ho jaye gi. Constructor values set kr rha hota hai aur values return nahi krta, values set krne me aur values return krne me farq hai. Constructor me hum woh kaam krte hain jo hum chahtey hain k jesey humara object initialize ho to woh call ho jaye.



FOR EXAMPLE: Jab koi insaan peda hota hai to us ki kuch values default me set hoti hain like; eyes ka color, hairs ka color, skin ka color etc to in properties ya values ko hum us insaan k constructor me initialize krwa den ge aur kuch properties ya values us insaan ki pehley se set nahi hongi like; naam etc to naam ki property hum khud set kren ge aur usey constructor me call nahi krwaye ge.



Constructor ka kaam hi properties me values set krna hota hai.

No comments:

Post a Comment