C # Programming Overview

Source: Internet
Author: User

C # Programming Overview A simple C # program

Identifier

An identifier is a string used to name variables, methods, parameters, and many other program structures that will be elaborated later.

Key words

All C # Keywords are made up of lowercase letters, but. NET type name using the Pascal casing convention.


Main: The starting point of the program
    • The executable starting point of a C # program is the first instruction in main
    • Main first letter must be capitalized
Output text from a program

The BCL (base Class Library) provides the console class (in the System namespace), which contains methods for entering and outputting data to the console.
Write

Console.Write ("This is trivial text.");


WriteLine

System.Console.WriteLine ("This is Text1."); System.Console.WriteLine ("This is Text2."); System.Console.WriteLine ("This is Text3.");


format string

Console.WriteLine ("Both sample integers is {0} and {1}.", 3,6);


Multiple tags and values

Console.WriteLine ("Three integers is {1},{0} and {1}.", 3,6);


Formatting numeric strings

Console.WriteLine ("The Value:{0}.", 500); Console.WriteLine ("The Value:{0:c}.", 500);

Justification specifier

int myint=500; Console.WriteLine ("|{ 0,10}| ", myInt); Console.WriteLine ("|{ 0,-10}| ", myInt);

Format field


Double mydouble=12.345678; Console.WriteLine ("{0,-10:g}--general", mydouble); Console.WriteLine ("{0,-10}--default,same as General", MyDouble); Console.WriteLine ("{0,-10:f4}--fixed point,4 Dec places", MyDouble); Console.WriteLine ("{0,-10:c}--currency", mydouble); Console.WriteLine ("{0,-10:e3}--sci.notation,3 dec places", MyDouble); Console.WriteLine ("{0,-10:x}--hexadecimal integer", 1194719);

Standard numeric format specifier


Comments

C # Programming Overview

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.