Govt. Exams
Entrance Exams
LINQ (Language Integrated Query) provides a unified syntax for querying different data sources like collections, databases, XML, etc. It allows developers to write queries in C# syntax.
'abstract' keyword creates a class that serves as a blueprint for derived classes and cannot be instantiated directly. Abstract classes can contain abstract methods that must be implemented by derived classes.
List<T> maintains insertion order and allows duplicates. HashSet<T> doesn't allow duplicates. Dictionary<K,V> maintains key-value pairs. SortedSet<T> keeps elements sorted without duplicates.
In C#, the == operator for strings compares their values, not references. Since both s1 and s2 contain "Hello", the result is true. This is different from object references comparison.
'params' allows a method to accept a variable number of arguments of the same type as an array. For example: void Method(params int[] numbers) can accept 0 or more integers.
Both int? and Nullable<int> represent the same nullable integer type. int? is the shorthand syntax for Nullable<int>. They allow the variable to hold a null value in addition to integer values.
Both int.Parse() and Convert.ToInt32() can convert strings to integers. int.TryParse() is safer as it returns a boolean indicating success/failure. All are valid approaches.
struct is a value type stored on the stack, while class is a reference type stored on the heap. struct does not support inheritance from other structs/classes (except interfaces), while classes do.
String interpolation uses the \( prefix with curly braces to embed expressions. Option C shows the correct syntax: \)"Hello {name}". The @ symbol creates verbatim strings, not interpolated strings.
++a is pre-increment, which increments 'a' to 6 first, then assigns it to 'b'. So both a and b become 6. Output is '6 6'.