Important Keywords in C#

CsharpProgrammingServer Side Programming

Some of the key keywords in C#, include.

  • Sealed
  • Params
  • Internal
  • this
  • abstract

Sealed

When you use sealed modifiers in C# on a method, then the method loses its capabilities of overriding. The sealed method should be part of a derived class and the method must be an overridden method.

Params

While declaring a method, you are not sure of the number of arguments passed as a parameter, then use params. C# param arrays can let you know about this.

Internal

Internal access specifier allows a class to expose its member variables and member functions to other functions and objects in the current assembly. Any member with internal access specifier can be accessed from any class or method defined within the application in which the member is defined.

this

The “this” keyword in C# is used to reference the current instance of the class. It is also used to differentiate between the method parameters and class fields if they both have the same name.

abstract

The abstract keyword in C# is used for abstract classes. An abstract class in C# includes abstract and non-abstract methods. You cannot instantiate an abstract class.

raja
Updated on 22-Jun-2020 07:34:54

Advertisements