2015-10-21 C # First Class

Source: Internet
Author: User

1. Understand the relationship between. NET and C #:

1.1:.net is a development platform

1.2:c# is a language applied on the. NET Platform

2. vs There are generally three types of projects that can be built:

2.1: Is the Windows Forms application, also is our commonly used C/s side application software;

2.2: Console application, mainly used to learn to debug C # code (teacher class application Mode);

2.3:web application, set up empty Web mode, b/s mode;

Web Forms application, the establishment will generate some common Web page components and functions, such as JS, image, etc., is also B/s mode.

  

3.C # Defines a method for a class:

4, the interpretation of the content of the category page:

  

5. Define a person's class (in Solution Explorer-right-add-new Item-Class)
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespacepro20150803{classPerson { Public stringName ="Xiaowang";  Public intAge =Ten;  Public voidSayhi () {Console.WriteLine ("Hello, I am a human being ."); }         Public intGetnum (inti) {i+=Ten; returni; }    }}/*a few explanations of the above code: 1, all variables and methods, if the non-public variable is a private type, can only be accessed in this class, other classes can not be called.  2, public string name = "Xiaowang"; Defines a string of characters. 3. public void Sayhi ()//define a method with no return type. 4, public int getnum (int i)///must return the value with return. */
6. Methods for invoking the person class
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespacepro20150803{classProgram {Static voidMain (string[] args) {Person P=NewPerson ();            Console.WriteLine (P.name);            Console.WriteLine (P.age);            P.sayhi (); Console.WriteLine (P.getnum ( -));        Console.readkey (); }    }}/*a few explanations of the above code: 1, person p = new person (); In C # 's program portal, instantiate a P object to invoke the value of person. 2, Console.Write does not wrap the output content, Console.WriteLine the line output content.  3, Console.readkey (); If this is not added, the program results will be closed automatically after execution. */
7. Canonical naming method and variable name

(1) The name of the class name and interface name is usually named by the noun, the first letter should be capitalized, if it is a combination of multiple words, the first letter of each word should be capitalized

(2) Variable names are generally lowercase nouns, method name verbs, and the first letter of a word capitalized, if multiple words are capitalized in the first letter.

(3) The name of the constant should be all uppercase and the word separated by an underscore

(4) The Class Name property name and method name cannot be a keyword

8. Numeric Type

The smallest unit of information for a computer is byte (bytes), a byte is 8 bits (bit), a letter is a byte, and a Chinese character is two bytes.

Name

Description

Occupied bytes

Range

Byte

BYTE type

1

-27~27-1

Short

Short-integer

2

-215~215-1

Int

Integral type

4

-231~231-1

Long

Long integer type

8

-263~263-1

Char

Character type

1

0~65535

Float

Single-precision

4

±1.5*10-45~±3.4*1038

Double

Double-precision Type

8

±5.0*10-324~±1.7*10308

bool

Boolean type

1

Only true and false two values

2015-10-21 C # First Class

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.