Type Casting:-
Aik data type ko doosri data type me convert krne ko hum type casting kehtey hain.
Aik game hai jis me aik box hota hai aur jab hum us box ko kholtey hain to us k ander aik chota box hota hai aur is chotey box k andar aik aur is se bhi chota box hota hai aur is tarha krtey krtey aakhir me aik machis ki dabi(match box) nikalti hai aur is machis ki dabi me tofi ya coin rakha hua hota hai, bilkul isi tarha type casting me hum size k hisab se bari data type ko choti data type me convert kr rhey hotey hain, is Phenomenon ko hum unboxing kehtey hain.
Paragraph#2 me di gai box wali example ko mad-e-nazar rakhtey huwey hum long data type me se interger data type nikaltey hain aur phir integer data type me se short data type nikaltey hain aur akhir me short data type me se byte data type nikaltey hain, agar humari desired value byte data type me hogi. Is Phenomenon ko hum boxing aur unboxing kehtey hain. Boxing aur unboxing k liye humey type casting ki zaroorat perhti hai.
Boxing aur unboxing me type cast krtey waqt agar long data type se byte data type me convert krna hai to humey koi zaroorat nai k pehley hum long data type ko integer data type, phir integer data type ko short data type aur phir akhir me short data type ko byte data type me cast kre, balkey hum C# me direct long data type ko byte data type me cast kre ge.
No comments:
Post a Comment