Section 1 C # basics-Section 1 C # programming Basics

Source: Internet
Author: User

Example 1

Solution: ConsoleApplication

Project name: leleapplication

File Name: Program. cs

 
Using System; using System. collections. generic; using System. text; namespace ConsoleApplication {class Program {static void Main (string [] args) {/* Console. writeLine ("hello"); string s = Console. readLine (); // when the user inputs text, it is paused. After the user inputs the text, press enter to return the user input and declare a string variable container.) s, use s to put the value returned by the ReadLine function. Console. writeLine (s + "hello"); */int i1 = 10; int i2 = 20; // Console. writeLine (i1 + "+" + i2 + "=" + (i1 + i2); // The placeholder starts from 0, the sequence starts with the second parameter of WriteLine // Console. writeLine ("{0} + {1} = {3}", i1, i2, i1 + i2, "aaa"); // string. format () Console. writeLine ("Enter the boy's name"); string boy = Console. readLine (); Console. writeLine ("Enter girl's name"); string girl = Console. readLine (); Console. writeLine ("{0} love {1}", boy, girl); // int i3 = "3"; // error, "3" just looks like a number, it is still a string // string boy = Console. readLine (); // error. The variable cannot be named again boy = Console. readLine (); // yes. Instead of redefining the boy variable, use the existing variable // boy = 3; // No, once the type is determined, no value can be assigned to other types of Console. readKey (); // press a key to continue execution }}}

Example 2
 

Solution: leleapplication1

Project name: leleapplication1

File Name: Program. cs

 
Using System; using System. collections. generic; using System. text; namespace ConsoleApplication1 {class Program {static void Main (string [] args) {/* int I = 10; Console. writeLine ("I"); // I and "I" only look the same. string name = Console. readLine (); Console. writeLine ("name hello"); // error Console. writeLine (name + ""); */string s = "\" AB \ ""; Console. writeLine (s); Console. readKey ();}}}

This article from the "white clouds out of this unintentional" blog, please be sure to keep this source http://chenbaiyun.blog.51cto.com/7361557/1300729

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.