Method:- A method is a set of one or more program statements, which can be executed by referring to the method name.
Define methods:-
<Access specifier> <Return Type> <Method Name>(Parameter List)
{
Method Body
}
The elements of the method declaration include the method name, the parameters list, the return type, and the method body.
The following are the elements of a method:
Access specifier
Return type
Method name
Parameter list
Method body
Example:-using System;
class Test
{
static void Main(string[] args)
{
Myclass obj = new Myclass();
obj.Show();
Console.ReadLine();
}
}
class Myclass
{
public void Show()
{
Console.WriteLine("Show Method");
}
}
Define methods:-
<Access specifier> <Return Type> <Method Name>(Parameter List)
{
Method Body
}
The elements of the method declaration include the method name, the parameters list, the return type, and the method body.
The following are the elements of a method:
Access specifier
Return type
Method name
Parameter list
Method body
Example:-using System;
class Test
{
static void Main(string[] args)
{
Myclass obj = new Myclass();
obj.Show();
Console.ReadLine();
}
}
class Myclass
{
public void Show()
{
Console.WriteLine("Show Method");
}
}
0 comments:
Post a Comment