標籤:single temp bool 符號 mes 表示 oat time names
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace _2017_10_30_shu_ju_lei_xing{ class Program { static void Main(string[] args) { Console.WriteLine("hello China"); //writeline可以放任意類型資料 Console.Write("hello world"); Console.WriteLine(12345678); //Console.Read(); //Console.Read();的傳回值是int型,主要作用停住。 //int temp = Console.Read(); string temp = Console.ReadLine(); Console.WriteLine(temp); Console.ReadKey(); //讀按鍵,按在控制台哪個輸出哪個 // Console.ReadLine(); int i; //整形,佔4位元組,表示32位整數,範圍從-2,147,483,648 到 2,147,483,647 var v = 1; //萬能類型,賦予什麼就是什麼 double d; //雙精確度浮點型,佔8個位元組,±5.0e?324 到 ±1.7e308 float f; //小數 decimal dec; //小數 bool b = false; //布爾型 true或者false short sh; //短整型,占 2 位元組,表示 16 位整數,範圍 -32,768 ~ 32,767 long lo; //長整型,占 8 位元組,表示 64 位元整數,範圍大約 -(10 的 19) 次方 到 10 的 19 次方 string s = "雙引號"; // char c = ‘單‘; //字元型,一個位元組 DateTime dt; // } }}
| 作用 |
|
大小 |
C# |
大小 |
.NET Framework類型 |
取值範圍 |
| 字元 |
|
1 |
sbyte |
1 |
System.SByte |
-128~127 |
| 字元(無符號) |
|
1 |
byte |
1 |
System.Byte |
0~255 |
| 寬字元 |
wchar_t |
2 |
char |
2 |
System.Char |
|
| 寬字元(無符號) |
unsigned wchar_t |
2 |
|
|
|
|
| 邏輯值 |
bool |
1 |
bool |
1 |
System.Boolean |
true,false |
| 短整數 |
short |
2 |
short |
2 |
System.Int16 |
-32,768 .. 32,767 |
| 短整數(無符號) |
unsigned short |
2 |
ushort |
2 |
System.UInt16 |
0~65535(2的16次方) |
| 整數 |
int |
4 |
int |
4 |
System.Int32 |
-2,147,483,648 .. 2,147,483,647 |
| 整數(無符號) |
unsigned int |
4 |
uint |
4 |
System.UInt32 |
0 .. 4,294,967,295 |
| 長整型 |
long |
8 |
long |
8 |
System.Int64 |
-9,223,372,036,854,775,808 .. 9,223,372,036,854,775,807 |
| 長整型(無符號) |
unsigned long |
8 |
ulong |
8 |
System.UInt64 |
0 .. 18,446,744,073,709,551,615 |
| 單精確度實數 |
float |
4 |
float |
4 |
System.Single |
-3.402823e38 .. 3.402823e38 |
| 雙精確度實數 |
double |
8 |
double |
8 |
System.Double |
-1.79769313486232e308 .. 1.79769313486232e308 |
| 長雙精確度實數 |
long double |
10 |
decimal |
16 |
System.Decimal |
-79228162514264337593543950335 .. 79228162514264337593543950335 |
| 字串 |
string |
|
string |
|
System.String |
|
| 對象 |
|
|
object |
|
System.Object |
|
C#基礎&&資料類型