Wednesday 3 February 2016

Lecture#1 ka Point#64 (Csharp Roman Hindi/Urdu Me).

Aik default behavior hai C#(.NET Framework) me type casting ka k jab hum choti se bari data type me move kr rhey hotey hain to value ko hum easily choti se bari data type k saath store kr saktey hain.

For Example:

Byte data type ki value ko agar hum short data type me store krwaye to woh easily store ho jaye gi. Is me type casting hogi aur value easily convert ho jaye gi aur humey value lost ho janey ka bhi khof nahi hoga. Isko hum "Implicit type casting" kehtey hain, jis me hum value choti data type se bari data type me convert kr rhey hotey hain.

"Implicit type casting" me agar hum type casting nahi krtey to C#(.NET Framework) ka default behavior hai k woh khud hi type casting kre ga. "Implicit type casting" ko hum "Boxing" bhi kehtey hain.

"Explicit type casting" ya "unboxing" jo hai "Implicit type casting" ya "boxing" ka ulat hogi bas farq(difference) sirf itna hoga k "implicit type casting" me type casting optional hogi jab k "explicit type casting" me type casting required ya mandatory hogi.

"Explicit type casting" me values lost honay ka chance hota hai.

For Example:

Agar humey aik barey(big) box ko chotey(small) box me daalna ho to big box kaat peet kr ya tor maror kr small box me chala to jaye ga lakin us big box ki original shape lost ho jaye gi.

Implicit Type casting with example code:
1 byte b = 100;
2 short s = (short) b;
3 Console.WriteLine(s);
4 Console.ReadLine();
Output: 100

Explicit Type casting with example code:
1 short s = 100;
2 // byte b = s; //error aa jaye ga.
3 byte b = (byte) s;
4 Console.WriteLine(b);
5 Console.ReadLine();
Output: 100

TIP: Acha programmer woh hota hai jo "explicit type casting" ho ya phir "implicit type casting", woh "explicit type casting" hi krta hai.

1 comment:

  1. How to Play Baccarat Online | Bet On The Moneyline
    Learn how to 메리트카지노 play baccarat online in 바카라 사이트 the US. Learn how to play casino 카지노 games & learn how to play roulette & blackjack at BetOnline.

    ReplyDelete