Govt. Exams
Entrance Exams
string str = "Hello";
str = str + " World";
Console.WriteLine(str.Length);
"Hello" has 5 characters. After concatenation with " World" (6 characters including space), the total length is 11.
The '?' suffix is used to declare nullable value types in C#. int? means an integer that can also hold null values.
LINQ (Language Integrated Query) is available in the System.Linq namespace introduced in .NET 3.5.
The default access modifier for class members is 'private'. For top-level classes, it's 'internal' by default.
The 'const' keyword creates a compile-time constant in C#. 'readonly' creates a runtime constant, 'static' defines class-level members, and 'immutable' is not a C# keyword.
Explicit casting from decimal to int truncates the decimal part, resulting in 10.
The ternary operator checks if x > y. Since 10 is not greater than 20, it returns y which is 20.
The 'const' keyword creates a constant that must be initialized at declaration and cannot be changed. 'readonly' allows initialization in constructor.
/* */ is used for multi-line comments in C#. // is for single-line comments.
Classes are reference types. byte, decimal are value types, and struct is also a value type.