Govt. Exams
Entrance Exams
'sealed' keyword prevents a class from being inherited. This is useful for security and performance optimization when you want to prevent further derivation.
'nameof()' operator (C# 6+) returns the name of a variable, type, or member as a string literal, useful for logging and validation.
'internal' access modifier restricts member access to the same assembly only. This is useful for creating assembly-wide internal APIs.
An abstract class uses the 'abstract' keyword, and abstract methods must be declared without implementation inside abstract classes.
C# does not support multiple class inheritance to avoid the diamond problem. However, a class can implement multiple interfaces.
In C#, the colon (:) is used to indicate inheritance. For example, 'class Child : Parent' creates a derived class.
The default access modifier for class members in C# is 'private', which restricts access to within the class only.
Auto-implemented properties in C# use the syntax: public Type PropertyName { get; set; } without explicitly defining the backing field.
Arrays in C# are automatically initialized with default values. For int arrays, the default value is 0. Therefore, the output will be five zeros separated by spaces.
Dictionary<K, V> stores key-value pairs and ensures unique keys. List stores ordered values, HashSet stores unique values only, Queue is FIFO.