Syntax


Syntax

C# is an object-oriented computer language. The software includes multiple objects through activities in Object-oriented Programming Metody. Methods are the actions an object can take, and objects of the same kind are said to be of the same type or class.

Let's look at an object, for example, a rectangle. It has features like width and length. Depending on the design, the values of these attributes can be accepted, the area calculated, and the details displayed.

The using Keyword

In every C# programme, the first statement is

using System;

The Keyword is used for the program to include namespaces. Multiple statements may be used for a program.

The class Keyword

The class keyword is used to declare a class.

Comments in C#

Code explanation comments are utilized, and compilers ignore the comment entries. In the C# applications, multi-line comments begin with/* and end with */.

Member Variables

Variables are class members or properties used for data storage. The previous program has length and width variables in the rectangle class.

Member Functions

Functions are a set of statements performing a certain activity. In the class, the member's functions are proclaimed. There are three functions in the sample class Rectangle: AcceptDetails, GetArea & Display.

Instantiating a Class

The ExecuteRectangle class has the Main() function, and the Rectangle class is instanced in the previous application.