// A class with a public variable and public method
class Computer
{
// variables
public string brand;
// No constructor, use default constructor
// methods
public string Start()
{
string str = brand + " Started";
return str;
}
// Overload method
public string Start(string mode)
{
string str = brand + " Started in " + mode + " Mode";
return str;
}
}
class Program
{
static void Main(string[])
{
Computer ibmComputer = new Computer;
ibmComputer.brand = "IBM";
Console.WriteLine(ibmComputer.Start("Safe"));
Console.ReadKey();
}
}
0 comments:
Post a Comment