Home  >  Article  >  Backend Development  >  C# learning object-oriented how to call classes and the use of ordinary methods and static methods

C# learning object-oriented how to call classes and the use of ordinary methods and static methods

little bottle
little bottleforward
2019-04-27 11:55:094670browse

The main content of this article is about how to call classes and the use of ordinary methods and static methods in the object-oriented process in C#. It has certain reference value and interested friends can learn about it.

Call of class

The namespace of the newly created class is the same as the namespace of the main function by default. If they are different, the main function cannot be called. Custom class

For example:

## Just need to reference it

If you don’t know the class name of the method, you can right-click the mouse → parse → using

Use of ordinary methods and static methods

Ordinary methods: need to instantiate objects, use objects Click it out

Static method: Use the class name directly to point it out, no need to instantiate the object

The console class method does not need to be executed in the main function Instantiation, how can the method be used without instantiation?

Just add static after the access modifier, for example:

##Related tutorials:

C Video Tutorial

The above is the detailed content of C# learning object-oriented how to call classes and the use of ordinary methods and static methods. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete