Govt. Exams
Entrance Exams
Lambda expressions (introduced in C# 3.0) are a concise form of anonymous functions. They can infer return types and parameter types, and can access outer scope variables.
Generic methods use angle brackets <T> after the method name. The syntax is: public void Method<T>() where T is the type parameter.
For strings in C#, '==' is overloaded to compare values, and Equals() also compares values. However, for other reference types, '==' compares references while Equals() compares values.
HashSet<T> is an unordered collection that automatically prevents duplicate values. List<T> allows duplicates.
5 > 3 is true, but 10 < 8 is false. The && (AND) operator returns false because one condition is false.
The 'out' keyword is used when a method needs to return a value through a parameter. The parameter must be assigned before the method exits.
++x is pre-increment, so x becomes 6, then y is assigned 6. Both x and y are 6.
String interpolation uses the $ prefix followed by curly braces containing expressions.
Accessing an array index beyond its bounds throws an IndexOutOfRangeException at runtime.
Properties can have get and set accessors independently with different access modifiers like public get, private set.