作者JoeHorn (每天都在公司玩OLG)
看板C_Sharp
标题[问题] 数值型态宣告
时间Tue Jul 20 02:25:27 2010
就我的认知。
short 跟 System.Int16 是相同的;
int 跟 System.Int32 是相同的;
long 跟 System.Int64 是相同的;
float 跟 System.Single 是相同的;
double 跟 System.Double 是相同的。
我都是使用後者,因为我怕 short/int/long/float/double 这类的宣告,
在 32-bit OS 跟 64-bit OS 值域会有差异。
可是.. 刚才在网路上,我看到这份文件:
http://weblogs.asp.net/lhunt/pages/CSharp-Coding-Standards-document.aspx
PDF 档里面的这段让我迷惑了:
1.4.3 Language Usage
Code Style
Native Data Types Use built-in C# native data types vs .NET CTS types.
(Use int NOT Int32)
小弟接触 C# 时间并不算久,大概是以下两个问题请教板上前辈们:
1. 就以 int/Int32 而言,使用哪一种作变数型态宣告会比较好呢?
原因是?
2. short/int/long/float/double 在 32-bit OS 跟 64-bit OS 的值域不同吗?
以上,先谢谢大家的指教。 <(_ _)>
--
Leo [joehorn]:~> make one lover for me
make: don't know how to make one. Stop
Leo [joehorn]:~> why?
why?: No match.
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.37.129.28
1F:→ deuter:通常用int比较好, 32/64都一样 07/20 11:42
3F:→ JoeHorn:为何用 int 会比较好呢? O_o 07/22 23:06
4F:→ deuter:因为大部分程式码都这样写,方便阅读, 而且可以少打两个键 07/23 10:45