正在阅读:初探c#(四)预定义类型初探c#(四)预定义类型

2004-02-14 09:34 出处:PConline 作者:依栏望海 责任编辑:pjl
我抄了一张预定义类型的简表供大家参考。 Type Description Examples object The ultimate base type of all other types object o = new Stack(); string String type; a string is a sequence of string s = "Hello"; Unicode characters sbyte 8-bit signed integral type sbyte val = 12; short 16-bit signed integral type short val = 12; int 32-bit signed integral type int val = 12; long 64-bit signed integral type long val1 = 12; long val2 = 34L; byte 8-bit unsigned integral type byte val1 = 12; byte val2 = 34U; ushort 16-bit unsigned integral type ushort val1 = 12; ushort val2 = 34U; uint 32-bit unsigned integral type uint val1 = 12; uint val2 = 34U; ulong 64-bit unsigned integral type ulong val1 = 12; ulong val2 = 34U; ulong val3 = 56L; ulong val4 = 78UL; float Single-precision floating point type float value = 1.23F; double Double-precision floating point type double val1 = 1.23 double val2 = 4.56D; bool Boolean type; a bool value is either bool value = true; true or false char Character type; a char value is a Unicode char value = 'h'; character decimal Precise decimal type with 28 significant digits decimal value = 1.23M; 你也可以自定义自己的预定义类型,可以这样: */ using System; struct Digit {...} class Test { static void TestInt() { int a = 1; int b = 2; int c = a + b; Console.WriteLine(c); } static void TestDigit() { Digit a = (Digit) 1; Digit b = (Digit) 2; Digit c = a + b; Console.WriteLine(c); } static void Main() { TestInt(); TestDigit(); } } /* 这一节有点沉闷。:(
键盘也能翻页,试试“← →”键

相关文章

关注我们

最新资讯离线随时看 聊天吐槽赢奖品