Home > Backend Development > C#.Net Tutorial > 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
Release: 2019-04-27 11:55:37
forward
4689 people have browsed it

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!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template