本文整理汇总了C#中Int16类的典型用法代码示例。如果您正苦于以下问题:C# Int16类的具体用法?C# Int16怎么用?C# Int16使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Int16类属于命名空间,在下文中一共展示了Int16类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Write
public override void Write(Int16 val)
{
val = Utilities.SwapBytes(val);
base.Write(val);
if (AutoFlush) Flush();
}
示例2: Channel
internal Channel(Int16 id, Layer layer)
{
ID = id;
Layer = layer;
Layer.Channels.Add(this);
Layer.SortedChannels.Add(ID, this);
}
示例3: BigEndian
/// <summary>
/// Converts a <see cref="Int16"/> to big endian notation.
/// </summary>
/// <param name="input">The <see cref="Int16"/> to convert.</param>
/// <returns>The converted <see cref="Int16"/>.</returns>
public static Int16 BigEndian(Int16 input)
{
if (!BitConverter.IsLittleEndian)
return input;
return Swap(input);
}
示例4: Document
public Document(
Int16 _TypeId,
Int64 _Serial,
Int32 _SignedUser,
DateTime _Date,
Boolean _Printed,
String _DocumentShortName,
String _DocumentFullName,
String _MedexDataTable,
String _DocumentBody,
String _DocumentHeader,
Boolean _SetDeleted
)
{
TypeId = _TypeId;
Serial = _Serial;
SignedUser = _SignedUser;
Date = _Date;
Printed = _Printed;
DocumentShortName = _DocumentShortName;
DocumentFullName = _DocumentFullName;
MedexDataTable = _MedexDataTable;
DocumentBody = _DocumentBody;
DocumentHeader = _DocumentHeader;
SetDeleted = _SetDeleted;
}
示例5: VerifyInt16ImplicitCastToComplex
private static void VerifyInt16ImplicitCastToComplex(Int16 value)
{
Complex c_cast = value;
if (false == Support.VerifyRealImaginaryProperties(c_cast, value, 0.0))
{
Console.WriteLine("Int16ImplicitCast ({0})" + value);
Assert.True(false, "Verification Failed");
}
else
{
if (value != Int16.MaxValue)
{
Complex c_cast_plus = c_cast + 1;
if (false == Support.VerifyRealImaginaryProperties(c_cast_plus, value + 1, 0.0))
{
Console.WriteLine("PLuS + Int16ImplicitCast ({0})" + value);
Assert.True(false, "Verification Failed");
}
}
if (value != Int16.MinValue)
{
Complex c_cast_minus = c_cast - 1;
if (false == Support.VerifyRealImaginaryProperties(c_cast_minus, value - 1, 0.0))
{
Console.WriteLine("Minus - Int16ImplicitCast + 1 ({0})" + value);
Assert.True(false, "Verification Failed");
}
}
}
}
示例6: Int16
public static byte[] Int16(Int16 i, Endianness e = Endianness.Machine)
{
byte[] bytes = BitConverter.GetBytes(i);
if (NeedsFlipping(e)) Array.Reverse(bytes);
return bytes;
}
示例7: Write
public static void Write(this BinaryWriter writer, Int16 value, bool invertEndian = false)
{
if (invertEndian)
{
writer.WriteInvertedBytes(BitConverter.GetBytes(value));
}
else
{
writer.Write(value);
}
}
示例8: VerifyInt16ImplicitCastToComplex
private static void VerifyInt16ImplicitCastToComplex(Int16 value)
{
Complex c_cast = value;
Support.VerifyRealImaginaryProperties(c_cast, value, 0.0,
string.Format("Int16ImplicitCast ({0})", value));
if (value != Int16.MaxValue)
{
Complex c_cast_plus = c_cast + 1;
Support.VerifyRealImaginaryProperties(c_cast_plus, value + 1, 0.0,
string.Format("PLuS + Int16ImplicitCast ({0})", value));
}
if (value != Int16.MinValue)
{
Complex c_cast_minus = c_cast - 1;
Support.VerifyRealImaginaryProperties(c_cast_minus, value - 1, 0.0,
string.Format("Minus - Int16ImplicitCast + 1 ({0})", value));
}
}
示例9: WriteArray
public override void WriteArray(string prefix, string localName, string namespaceUri, Int16[] array, int offset, int count)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.GetString(SR.JsonWriteArrayNotSupported)));
}
示例10: TryToInt16
internal static Exception TryToInt16(string s, out Int16 result) {
if (!Int16.TryParse(s, NumberStyles.AllowLeadingSign|NumberStyles.AllowLeadingWhite|NumberStyles.AllowTrailingWhite, NumberFormatInfo.InvariantInfo, out result)) {
return new FormatException(Res.GetString(Res.XmlConvert_BadFormat, s, "Int16"));
}
return null;
}
示例11: VerifyInt16ImplicitCastToBigInteger
private static void VerifyInt16ImplicitCastToBigInteger(Int16 value)
{
BigInteger bigInteger = value;
Assert.Equal(value, bigInteger);
Assert.Equal(value.ToString(), bigInteger.ToString());
Assert.Equal(value, (Int16)bigInteger);
if (value != Int16.MaxValue)
{
Assert.Equal((Int16)(value + 1), (Int16)(bigInteger + 1));
}
if (value != Int16.MinValue)
{
Assert.Equal((Int16)(value - 1), (Int16)(bigInteger - 1));
}
VerifyBigIntegerUsingIdentities(bigInteger, 0 == value);
}
示例12: Write
public void Write(Int16[] value, int offset, int count)
{
const int size = sizeof(Int16);
CreateBuffer(size * count);
for (int i = 0; i < count; i++)
{
Array.Copy(BitConverter.GetBytes(value[i + offset]), 0, buffer, i * size, size);
}
WriteBuffer(size * count, size);
}
示例13: Int16ToBytes
/// <summary>
/// Converts int16 to the array of bytes size 2
/// </summary>
/// <param name="value">Int16 value</param>
/// <returns>Array of bytes of size 2.</returns>
public static byte[] Int16ToBytes(Int16 value)
{
return Int32ToBytes(value, 2);
}
示例14: WriteArray
public override void WriteArray(string prefix, string localName, string namespaceUri, Int16[] array, int offset, int count)
{
throw new NotSupportedException(SR.JsonWriteArrayNotSupported);
}
示例15: Push
public void Push(Int16 value)
{
Data[StackIndex++] = value;
}