"2017-2-17" vs basic applications and C # Basics section I (Defining variables, inputs, and outputs)

Source: Internet
Author: User

One vs basic applications

(i) New project

There are several ways to create a new project, such as:

1. Create a new project on the VS start Page

2, in the integration environment, through the "file"/"New"/"project", The New Project dialog box appears, where you select c#-Console application-Framework FRAMEWORK4, complete the new

3. In the open project, right-click/Add/New project in Solution Manager

(ii) BASIC applications

1, in Tools/Options/environment/general can set themes, fonts and colors can set the code font color in the project

2, in the text editor/c# can set the line number

Two C # basics

The completion of a new project has five elements: C #, Frame 4.0, console application, save location, file naming

The completion of the code is mainly done in the main function, the main function has four elements: name, input, output, processing

(i) Output

Console.WriteLine ("What to write");//output content, wrap, or cursor at the next

Console.Write ("content");//Do not wrap, that is, the cursor in the rear

Console.ReadLine ();//wait for input, enter content to continue, prevent flash back

For example:

            Console.WriteLine (" keyboard knocking ");            Console.WriteLine (" over million monthly salary ");            Console.ReadLine ();            Console.WriteLine (" keyboard ash ");            Console.ReadLine ();            Console.WriteLine (" home beggar ");            Console.ReadLine ();

(ii) input

1, if you have output in the code want content is Console.ReadLine (); only as a complete code output of the program to prevent the flash back, no significance.

2. Input variable, complete output

(1) Defining variables

First, define a variable A, then assign the value a= input console.readline (), enter the content you want to input, and then output, the variable can be input or any character. For example:

string a = console.readline ();             string " , Hello! ";             string c = a + b;            Console.WriteLine (c);            Console.ReadLine ();

Note: the "+" here is a combination of two sentences, and how is the data addition and subtraction implemented?

It is necessary to make use of integer variable int to compute the integer variable A, and then assign the value a= any number to realize the operation.

For example:

int 1 ;             int 2 ;             int C = a + b;            Console.WriteLine (c);            Console.ReadLine ();

Two different variable operations are implemented, and can be converted between them?

If the string is a number that can be converted, first define the string a= "any number", and then define the int b=int. Parse (a)

Comprehensive Walkthrough:

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 (""---------------------------""); stringf=a+"Hi there! Your gender is ""+b+"", your age is""+c+""Your height is""+d+""Your weight is""+e+"". ";            Console.Write (f); intg =int.            Parse (d); inth =int.            Parse (e); intz = g +h; stringx ="your height and weight are ""+ z +"". ";            Console.Write (x); Console.ReadLine ();

"2017-2-17" vs basic applications and C # Basics section I (Defining variables, inputs, and outputs)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.