C # basics

Data output to the screen 
Console.WriteLine (); 
Console.ReadLine (); // read data read from the screen 
waiting for the operation 
the Console.ReadKey () 
corresponds to the C ++ the System ( " PAUSE " ) 

///// /
 C # 15 predefined type 
13 is the value of the type 
2 is a reference type (string, and object): in C #, all types derive from object 
custom type 
value type: struct (structure), enum (enumeration) 
cited type: class (class) 



////// data type to 
a value of type -> reference types:
     int intNum = 12 is ;
     1 . Object objNum = ( Object ) intNum;
     2 (implicit conversion).Object objNum = intNum;
 2 . reference type -> Value Type 
    Integer Type: 
    Object objA = 15 ;
     // 1.int intGetobjA = (int) objA;
     // 2.int intGetobjA2 = Convert.ToInt32 (objA); 
    single-precision floating point type
     Object objB = 12.2 ;
     // 1.float GetobjB = (a float) objB;
     // 2.float GetobjB = Convert.ToSingle (objB); 
    double-precision floating point type
     Object ObjC = 15.5 ;
     // 1.double GetobjC = (Double) ObjC;
     // 2.Double GetobjC = Convert.ToDouble (ObjC); 
    


////// data type clear
After adding a numerical symbol to clear his data type 
such as: 
double A = 12.2 ; // (default type double) 
float B = 12.2F ; // clear to float 

int A = 10 ; // word section 
uint a = 10U ; // unsigned: a byte 
Long Longa = 10L ; 



////// random 
int index = new new the random () the Next (. 0 , . 5 )            // generates a random number of 0-5

 

Guess you like

Origin www.cnblogs.com/god-for-speed/p/11445049.html