In C#
Customer is a static class, and Buy() is a static method of the class Customer. To call the method Buy(), I should write:
Answer::
I am explaining the question with help of small program which will help you to understand.And also I have added information related to it as comments in program.
using System;
//static class Customer
public static class Customer
{
//static method Buy()
public static void Buy()
{
Console.WriteLine("Buy() method called"); //some statements
}
}
class MainClass {
public static void Main (string[] args) {
//Here we are calling our static Buy() method of static class Customer
//In C#, static means something which cannot be instantiated. You cannot create an object of a static class and cannot access static members using an object.
//you can user Class name while calling a method of that class.
Customer.Buy();
}
}
Output::
Use the above as reference.If any problem comment.
Get Answers For Free
Most questions answered within 1 hours.