Red for keywords, blue for syntax, purple for attention.
The first C # console application:
(Open vs, select "Console Application" to automatically generate C # programming infrastructure)
1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 6 namespaceHelloWorld (space name)7 {8 classProgram (class name)9 {Ten Static voidMain (string[] args) One { A //"Hello world!" is displayed to the user . -Console.WriteLine ("Hello world!");//this is handwritten. - } the } -}The first C # program
Annotations:
using: Importing namespaces
similar to : import (Java)
#include (C language)
namespace: For declaring namespaces (defining and creating your own namespaces)
similar to : Package (Java)
class: Declaring classes
Mian Method : Program entry
Variables and constants: (Naming rules)
Variable:
syntax: data type variable name;
1. In C #, variables are only declared and initialized before they can be used
2. Variable names are case-sensitive in C #
Constant:
Syntax: Const data type constant name;(usually the constant name is capitalized)
C # Basics