Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Case Analysis of basic Grammar of C #

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people do not understand the knowledge points of this "C# basic Grammar case Analysis" article, so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "C# basic Grammar case Analysis" article.

one。 Basic grammar

1.C# is case-sensitive, so myVar and MyVar are two different variables.

two。 Every C# executable (such as console applications, Windows applications, and Windows services) must have an entry point-Main () (M uppercase)

Public static void Main () {/ / do something}

This method is called when the program starts. This method either returns no value (void) or returns an integer (int)

two。 Variable

1. The compiler does not allow uninitialized variables to be used in expressions. If the variables are fields in a class or structure, if they are not initialized, when they are created, the default value is 0.

two。 Type inference

Type inference (type inference) uses the var keyword. The compiler can "infer" the type of a variable based on its initialization value. Var somenum = 0; even if somenum is never declared as int, the compiler can determine that as long as somenum is within its scope, it is an int. After the variable is declared and the type is inferred, the variable type cannot be changed. Once the type of the variable is determined, the strongly typed rules followed by other variable types are followed.

3. Scope of variables

The scope of a variable is the area of code that accesses the variable. As long as the scope of the variable is different parts of the program, there will be no problem.

(1)。 Scope conflict of local variables

Public static int Main () {int j = 20; for (int item0)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report