ushort
|
|
|
|
---|---|---|---|
|
|
|
文本
ushort myShort = 65535;
public static void SampleMethod(int i) {} public static void SampleMethod(ushort s) {}
// Calls the method with the int parameter: SampleMethod(5); // Calls the method with the ushort parameter: SampleMethod((ushort)5);
转换
ushort x = 5, y = 12;
ushort z = x + y; // Error: conversion from int to ushort
ushort z = (ushort)(x + y); // OK: explicit conversion
int m = x + y; long n = x + y;
// Error -- no implicit conversion from double: ushort x = 3.0; // OK -- explicit conversion: ushort y = (ushort)3.0;
C# 语言规范
有关更多信息,请参见C# 语言规范。 该语言规范是 C# 语法和用法的权威资料。