class Program
{
static void Main(string[] args)
{
//整型
int MyInt1 = 200000;
long MyLong = 2555555555555;
byte MyByte = 255;
//浮点型
float MyFloat = 3.14F;//定义浮点型后面加F;32位
double MyDouble = 3.14;//不用写f,浮点型;64位
decimal MyDecimal = 3.14M;//高精度浮点;128位
bool MyBool = true;//只有true或false;
char MyChar = 'w';//单个字符;
string MyStr = @"我是一\n个中国人";//@屏蔽转移符
// "\"是转义符的意思
Hero hero = new Hero();//调用类之前,先new 类;
Console.WriteLine("{0}",hero.HeroName);
int HeroLv = 22;
object Obj = HeroLv;//object 父对象派生;
string Name = @"""f1""";//会把一对引号去掉;
byte byte1 = 112;
byte byte2 = 113;
int byte3;
byte3 = byte1 + byte2;//书相加后都强行int;
long Mylong1 = 23;
int MyInt = (int)Mylong1;//强行转换成整形;
double MyDou = 22.22;
byte3 = Convert.ToInt32(MyDou);//convert 强行转换;
Console.ReadKey();
}
}
public class Hero
{
public string HeroName = "火云邪神";
public int HeroHp = 12500;
public double HeroMp = 250.250;
}
|