First, C # Language Foundation
New project: file → new → project →Visual C #(default . NET Framework 4.5) → console application
1. Project structure
(1) project suffix
. config --configuration file (storage configuration parameter file)
. csproj --project file (management file entry)
. sln -Solution files (Manage projects)
. CS --(program code)
(2) Four elements of the function: name, input, output, processing
(3) main function, input statement, output statement
Useing --Library referenced by the program
Namespace consoleapplication3--namespace
Class program--Classes
static void Main (string[] args)--method
(4) shortcut keys
alt+→ prompt, click Start or Ctrl+f5 when you need to execute the program
Ctrl+e,c Comment Bank ctrl+e,c uncomment the bank
(5) Comment method
A// comment line
/**/ Comment section
put it on the function and annotate the function.
Ii. Types of data
1. Basic data type (value type)
int integer type Int32 is 4b in size (range:-2^31 to 2^31-1)
Long Large integer type Int64 is 8b in size (range:-2^62 to 2^62-1 )
double dual-precision floating-point decimal size 8b
Decimal Single-precision floating-point decimal fraction of 16b size
String literal type
2. Reference type
(1) String type
String is equivalent to a character type, long, and is defined by double quotation marks
such as:string a = "Hello."; String B = "15";
(2) array type
Int a = 11; Double b = 12.5;
3. Basic type Conversion
(1) automatic conversion (implicit conversion)-when converting from a value type to a reference type
Method: Int a = 5;
String B = a.tostring ();
(2) casts (explicit conversions)-when converting from a reference type to a value type, or from a floating-point type to an orthopedic
when you convert from a reference type to a value type, you must reference the data element in the type, which can be converted to a value type in the capacity range, or you cannot go
method One: with ()
int A;
Double b = 12.3;
A = (int) b;
Method Two: with Convert
Int A; float C; Doulbe b=12.3;
A=convert.toint32 (b); C=convert. ToSingle (b);
method Three: with Parse
Int A; Double b=12.3;
A=int. Parse (b);
Summary:b= (ing) A; equivalent to B=int. Parse (a); equivalent to B=convert. ToInt32 (a);
Third, operator
arithmetic
+ + + + +- - minus * multiply / divide % take more + plus - minus
Relationship
> Greater than < less than >= greater than or equal to <= less than equals = = equals ! = does not equal
Logic
&& with (and) | | or ! Non (note: highest priority!) )
Conditional Operators
? : If it is
Assign Value
= += -= *= /= %=
For example:x+=5 is x=x+5
Example:
Console.Write (" Please enter the number within the range:");
String s = console.readline ();
Int num = Convert.ToInt32 (s);
Console.WriteLine (" number is a multiple of 7" + (num%7==0));
Console.WriteLine (" Number 10 digits is a multiple of 7" + (num/10==7));
Console.WriteLine (" digit single digit is a multiple of 7" + (num%10==7));
Language Basics + data type + operators