We can declare a class using the keyword "class" ,which following syntax:
[access-modifier] keyword class class-name {class-body}
for example
public class addmethod {
//class-body
}
The syntax elements are as follows:
access-modifier The degree to which your class is available to the outside world.
class-name The name you assign to your class.
The syntax elements are as follows:
access-modifier The degree to which your class is available to the outside world.
it may be public, private, protected etc.
class-name The name you assign to your class.
"addmethod" is the name of our class
class-body The body of your class.
Classes are usually declared using the public access modifier, meaning that the class is available without restriction
class-body The body of your class.
Classes are usually declared using the public access modifier, meaning that the class is available without restriction
public class Car
{
// declare the fields
public string make;
public string model;
public string color;
public int yearBuilt;
// define the methods
public void Start()
{
System.Console.WriteLine(model + " started");
}
public void Stop()
{
System.Console.WriteLine(model + " stopped");
}
}
