Govt. Exams
Entrance Exams
Value types (struct) are allocated on the stack, while reference types (class) are allocated on the heap.
Array.Resize() creates a new array of specified size and copies elements from the original array using the ref parameter.
C# has float (4 bytes) and double (8 bytes), but not float32. sbyte, uint, and decimal are valid types.
In C#, structs are value types (stored on stack) while classes are reference types (stored on heap). This is a fundamental difference between the two.
int x = 10;
int y = 20;
int z = x++ + ++y;
Console.WriteLine(x + " " + y + " " + z);
x++ returns 10 then increments x to 11. ++y increments y to 21 then returns 21. z = 10 + 21 = 31. Final output: 11 21 31