本文整理匯總了C#中System.Int32結構體的典型用法代碼示例。如果您正苦於以下問題:C# Int32結構體的具體用法?C# Int32怎麽用?C# Int32使用的例子?那麽, 這裏精選的結構體代碼示例或許可以為您提供幫助。
Int32結構體屬於System命名空間,在下文中一共展示了Int32結構體的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1:
sbyte value1 = 124;
short value2 = 1618;
int number1 = value1;
int number2 = value2;
示例2: catch
long lNumber = 163245617;
try {
int number1 = (int) lNumber;
Console.WriteLine(number1);
}
catch (OverflowException) {
Console.WriteLine("{0} is out of range of an Int32.", lNumber);
}
double dbl2 = 35901.997;
try {
int number2 = (int) dbl2;
Console.WriteLine(number2);
}
catch (OverflowException) {
Console.WriteLine("{0} is out of range of an Int32.", dbl2);
}
BigInteger bigNumber = 132451;
try {
int number3 = (int) bigNumber;
Console.WriteLine(number3);
}
catch (OverflowException) {
Console.WriteLine("{0} is out of range of an Int32.", bigNumber);
}
輸出:
163245617 35902 132451