Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace MyNamespace
- {
- class Program
- {
- static void Main(string[] args)
- {
- // Types
- // 1. Value memory size
- // 9456 - 32 bits
- // int i = 4;
- // byte b = 4;
- // 2. Value kind
- // int i1 = "1"; ERROR!
- // int i2 = 4.8; ERROR!
- // 'A' => 65
- // int i3 = 'A';
- // 3. Value operators
- // int i1 = 3;
- // i1 = i1 + 32;
- // bool b1 = false;
- // b1 = !b1;
- // string str = "AZE"; // string is reference type
- // str = str * 56; ERROR
- // str = str + "RBAIJAN";
- // Value Types
- // int a = 2;
- // int b = 54;
- // 'b' assign to 'a'
- // a = b; // a = 54, b = 54
- // a = 34; // a = 34, b = 54
- // System.Console.WriteLine("b: " + b);
- /*
- MyStruct ms1 = new MyStruct();
- ms1.x = 1;
- ms1.y = 2;
- ms1.z = 3;
- MyStruct ms2 = new MyStruct();
- ms2.x = 4;
- ms2.y = 5;
- ms2.z = 6;
- ms1 = ms2; // Copy
- ms2.x = 10;
- ms2.y = 11;
- ms2.z = 12;
- System.Console.WriteLine(ms1.x);
- System.Console.WriteLine(ms1.y);
- System.Console.WriteLine(ms1.z);
- */
- /*
- // Reference Types
- MyClass mc1 = new MyClass();
- mc1.x = 1;
- mc1.y = 2;
- mc1.z = 3;
- MyClass mc2 = new MyClass();
- mc2.x = 4;
- mc2.y = 5;
- mc2.z = 6;
- mc1 = mc2; // Copy
- mc2.x = 10;
- mc2.y = 11;
- mc2.z = 12;
- System.Console.WriteLine(mc1.x);
- System.Console.WriteLine(mc1.y);
- System.Console.WriteLine(mc1.z);
- */
- // MyClass1 mc1 = new MyClass2(); // ERROR
- // MyClass2 mc2 = new MyClass1(); // ERROR
- }
- // MyClass is reference type
- class MyClass1
- {
- public int x;
- public int y, z;
- }
- class MyClass2
- {
- public int x;
- public int y, z;
- }
- // MyStruct is value type
- struct MyStruct
- {
- public int x;
- public int y, z;
- }
- }
- }
Add Comment
Please, Sign In to add comment