C# :數據類型

 
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace test1
  5. {
  6.      struct phonebook{
  7.     
  8.          public string name;
  9.          public string phone;
  10.          public string address;
  11.     }
  12.     enum season {spring , summer,autumn,winter};
  13.     class Program
  14.     {
  15.         static void Main(string[] args)
  16.         {
  17.             //////////////////////////////////////////////////////////////////////////////////////
  18.             Console.WriteLine("整數類型");
  19.             Console.WriteLine("the sbyte : " + sbyte.MaxValue + " and  " + sbyte.MinValue);
  20.             Console.WriteLine("the short :" + short.MaxValue + " and " + short.MinValue);
  21.             Console.WriteLine("the int   :" + int.MaxValue + "and "int.MinValue );
  22.             Console.WriteLine("the byte  :" + byte.MaxValue +"and "byte.MinValue);
  23.             Console.WriteLine("the ushort:" + ushort.MaxValue +"and "ushort.MinValue);
  24.             Console.WriteLine("the uint  :"uint.MaxValue+"  and  " + uint.MinValue);
  25.             Console.WriteLine("the ulong  :"+ulong.MaxValue+ "  and  "+ulong.MinValue);
  26.            //////////////////////////////////////////////////////////////////////////////////////
  27.             Console.WriteLine("浮點類型");
  28.             Console.WriteLine("the float :"float.MaxValue +" and  "float.MinValue);
  29.             Console.WriteLine("the double" +double.MaxValue+ " and "double.MinValue);
  30.             ////////////////////////////////////////////////////////////////////////////////////
  31.             Console.WriteLine("十進制類型");
  32.             Console.WriteLine("the decimal :" + decimal.MaxValue + " and  " + decimal.MinValue);
  33.             ////////////////////////////////////////////////////////////////////////////////////
  34.             Console.WriteLine("布爾類型");
  35.             Console.WriteLine("the bool :" + bool.FalseString+" and  " + bool.TrueString);
  36.             ////////////////////////////////////////////////////////////////////////////////////
  37.             Console.WriteLine("字符類型");
  38.             Console.WriteLine("位數爲16/t,取值範圍:在0和65535之間以雙字節編碼的任意字符");
  39.             ////////////////////////////////////////////////////////////////////////////////////
  40.             Console.WriteLine("枚舉類型");
  41.             int s = (int)season.spring;
  42.             int s1 = (int)season.summer;
  43.             int s2 = (int)season.autumn;
  44.             int s3 = (int)season.winter;
  45.             Console.WriteLine("enum season {spring , summer,autumn,winter};");
  46.             Console.WriteLine("season.spring is :" + s);
  47.             Console.WriteLine("season.summer is :" + s1);
  48.             Console.WriteLine("season.autumn is :" + s2);
  49.             Console.WriteLine("season.winter is :" + s3);
  50.                        
  51.             //////////////////////////////////////////////////////////////////////////////////////
  52.             Console.WriteLine("結構類型");
  53.             phonebook pb;
  54.             pb.name = "mike";
  55.             pb.phone = "135769478**";
  56.             pb.address = "NanChang";
  57.             Console.WriteLine(pb.name +"/t"+ pb.phone+"/t"+pb.address);
  58.             /////////////////////////////////////////////////////////////////////////////////////
  59.         }
  60.     }
  61. }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章