Wednesday 26 April 2017

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

byte, short, integer aur long data type ki by-default value "0" hogi (for signed and unsigned data types). boolean data type ki default value "False" hogi. "char" aur "string" data type ki default value "empty" hogi. "decimal", "float" aur "double" ki default value "0" hogi.


Agar boolean ki 8bits me se 7bits "0" ya "OFF" hain aur 1bit "1" ya "ON" hai to answer "TRUE" aye ga kyun k in tamam 8bits me se 1bit "ON" ya "1" hai.


"NULL" ko hum special data type bhi kehtey hain.


"Heap" and "Stack" is basically a type of memory.


PROPERTIES (BASIC MEMBER OF CLASS):  


Purani languages me class me properties ka concept nahi hota tha. Properties hum use krtey hain to "get" and "set" a value "To/From" the variable.


Error humare pass 3 types k hotey hain.


  1. Compile time error.
  2. Runtime error.
  3. Logical error.




"Logical error" woh error hota hai jo input ki wajah se ata hai. FOR EXAMPLE: Jesey k student ka Roll# hai woh hamesha "positive" me hoga lakin agar user "negative" me input dega to woh logical error kehlaye ga. Logical errors ko control krne k liye hum program me kuch modifications kre ge aur properties bnaye ge.


Syntax of property
Public int RollNo{.....} → Property
Public int RollNo; → variable

Purani languages me hum variable me value "set" aur "get" krne k liye hum functions bnatey thay. FOR EXAMPLE: getRollNo() aur setRollNo(). Lakin .NET Framework me values ko "get" aur "set" krwane k liye hum propertties bnatey hain.
Line No. Code Comments
1 class Student
2  {
3  Public int rollno; //instance variable or data member.
4  Public int RollNo //property or function member.
5   {
6   get
7    {
8    return rollno;
9    }
10   set
11    {
12    rollno = value; //"value" is a keyword. jo value RollNo ki set kre ga woh value hi is "value" ke keyword me aye gi.
13    }
14   }
15  }
16 class Program
17  {
18  static void Main(string[] args)
19   {
20   Student Haroon = new Student();
21   Haroon.RollNo = 4945; //to set the property "RollNo"
22   Console.WriteLine(Haroon.RollNo); //to get the property "RollNo"
23   Console.ReadLine();
24   }
25  }
OUTPUT:                  4945

No comments:

Post a Comment