1, beginner C #.
C # is specifically designed for. NET application, he absorbed the advantages of C + +, Visual Basic, Delphi, Java and other languages, and improved the efficiency of program development.
2, the Visual Studio.NET integrated development environment.
The initial operation is divided into 5 steps: Open vs, click "File" in the upper left corner, select "New" "Project"-The new form will open. Select the C # Framework 4.0 Console application to save the location file naming.
3, the code is written.
Write the code in the main function. There is only one main function in a project.
Output: Console.WriteLine ("Content to Output");//outputs the contents outward, and wraps it automatically.
Console.Write ("Content to Output");//output content outside, not wrapped.
Console.ReadLine ();//wait for user input, press ENTER to end, to prevent the program to flash back.
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespace_0216 First Solution {classProgram {Static voidMain (string[] args) {Console.WriteLine ("keyboard Smash"); Console.WriteLine ("monthly salary over million"); Console.ReadLine (); Console.WriteLine ("keyboard Dust"); Console.ReadLine (); Console.WriteLine ("Go home Begging"); Console.ReadLine (); } }}
4, define variables, data input.
Set a variable before assigning a value to the variable. The name of the cut definition variable is not repeatable. If you already have string a, you can no longer set int a.
The variable you set can be understood as a box, and the variable assignment can be understood as loading something into the box and having a box before it can be loaded.
What to print: Console.WriteLine ("Output content");
Console.Write ("Content of output");
In the case of a print variable, there is no double quotation mark in parentheses: Console.WriteLine (variable name);
Console.Write (variable name);
To receive user input:
Console.ReadLine (); -Returns a string (string) type of value
The addition of variables defined by string is concatenation.
Defining variables: String A;
Variable assignment: a = "value";
Two sentences merged: string a= "value";
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceEnter {classProgram {Static voidMain (string[] args) {Console.Write ("Please enter your name:"); stringName =Console.ReadLine (); stringnihao="Hello"; stringc = Nihao +name; Console.WriteLine (c); Console.ReadLine (); } }}
5. Define integer variables.
int A;
Integer variable assignment:
A = 1;
The difference between int and string: int can only be assigned a number, and string can be assigned to any string.
int can perform a "+-*/" operation with the result of a mathematical calculation. String can only "+" result in the concatenation of the two.
How to convert a string string type to an int integer type:
String a = "10";
int b =int. Parse (a);
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceExercises 1{classProgram {Static voidMain (string[] args) {Console.Write ("Please enter your name:"); stringA =Console.ReadLine (); Console.Write ("Please enter your gender:"); stringb =Console.ReadLine (); Console.Write ("Please enter your age:"); stringc =Console.ReadLine (); Console.Write ("Please enter your height:"); stringD =Console.ReadLine (); Console.Write ("Please enter your weight:"); stringE =Console.ReadLine (); Console.WriteLine ("--------------------Gorgeous split-line-----------------------"); Console.WriteLine (A+"Hi there! Your gender is ""+ B +"", your age is""+c+"", your height is""+d+""and your weight is""+e+"". "); Console.ReadLine (); } }}
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceExercises 2{classProgram {Static voidMain (string[] args) {Console.Write ("Please enter your name:"); stringA =Console.ReadLine (); Console.Write ("Please enter your gender:"); stringb =Console.ReadLine (); Console.Write ("Please enter your age:"); stringc =Console.ReadLine (); Console.Write ("Please enter your height:"); stringD =Console.ReadLine (); Console.Write ("Please enter your weight:"); stringE =Console.ReadLine (); Console.WriteLine ("--------------------Gorgeous split-line-----------------------"); Console.WriteLine (A+"Hi there! Your gender is ""+ B +"", your age is""+ C +"", your height is""+ D +""and your weight is""+ E +"". "); intf =int. Parse (d); intg =int. Parse (e); inth = f +G; Console.Write ("your height and weight are ""+h+"". "); Console.ReadLine (); } }}
Small white for the first time to share, laughed at!
"2017-2-17" C # Fundamentals-Define variables, input and output