本文整理汇总了C#中System.UInt16类的典型用法代码示例。如果您正苦于以下问题:C# UInt16类的具体用法?C# UInt16怎么用?C# UInt16使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UInt16类属于System命名空间,在下文中一共展示了UInt16类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WithRefsWithReturn
public object WithRefsWithReturn(
ref string param1,
ref int param2,
ref short param3,
ref long param4,
ref uint param5,
ref ushort param6,
ref ulong param7,
ref bool param8,
ref double param9,
ref decimal param10,
ref int? param11,
ref object param12,
ref char param13,
ref DateTime param14,
ref Single param15,
ref IntPtr param16,
ref UInt16 param17,
ref UInt32 param18,
ref UInt64 param19,
ref UIntPtr param20
)
{
throw new Exception("Foo");
}
示例2: Person
public Person(string firstName, string lastName, UInt16 age, Person bestFriend = null)
{
this.firstName = firstName;
this.lastName = lastName;
this.age = age;
this.bestFriend = bestFriend;
}
示例3: SendMessage
public bool SendMessage(UInt16 ip, byte code, string body = null)
{
if (!IsConnected())
return false;
var hasBody = !string.IsNullOrEmpty(body);
var msg = new byte[hasBody ? 5 + body.Length : 3];
var ipbs = BitConverter.GetBytes(ip);
msg[0] = ipbs[0];
msg[1] = ipbs[1];
if (hasBody)
code |= 1 << 7;
msg[2] = (byte)code;
if (hasBody)
{
var lbodybs = BitConverter.GetBytes(body.Length);
msg[3] = lbodybs[0];
msg[4] = lbodybs[1];
var bodybs = System.Text.Encoding.ASCII.GetBytes(body);
Array.Copy(bodybs, 0, msg, 5, body.Length);
}
return _device.Write(msg) > 0;
}
示例4: StartWebDAV
/// <summary>
/// Start the WebDAV interface using the given ip address, port and HTTPSecurity parameters.
/// </summary>
/// <param name="myIPAddress">The IPAddress for binding the interface at</param>
/// <param name="myPort">The port for binding the interface at</param>
/// <param name="myHttpWebSecurity">A HTTPSecurity class for checking security parameters like user credentials</param>
public static Exceptional<HTTPServer<GraphDSWebDAV_Service>> StartWebDAV(this AGraphDSSharp myAGraphDSSharp, IPAddress myIPAddress, UInt16 myPort, HTTPSecurity myHttpWebSecurity = null)
{
try
{
// Initialize WebDAV service
var _HttpWebServer = new HTTPServer<GraphDSWebDAV_Service>(
myIPAddress,
myPort,
new GraphDSWebDAV_Service(myAGraphDSSharp),
myAutoStart: true)
{
HTTPSecurity = myHttpWebSecurity,
};
// Register the WebDAV service within the list of services
// to stop before shutting down the GraphDSSharp instance
myAGraphDSSharp.ShutdownEvent += new GraphDSSharp.ShutdownEventHandler((o, e) =>
{
_HttpWebServer.StopAndWait();
});
return new Exceptional<HTTPServer<GraphDSWebDAV_Service>>(_HttpWebServer);
}
catch (Exception e)
{
return new Exceptional<HTTPServer<GraphDSWebDAV_Service>>(new GeneralError(e.Message, new System.Diagnostics.StackTrace(e)));
}
}
示例5: GroupFoundEventArgs
public GroupFoundEventArgs (Byte connection, UInt16 start, UInt16 end, Byte[] uuid)
{
this.connection = connection;
this.start = start;
this.end = end;
this.uuid = uuid;
}
示例6: IndexBuffer
public IndexBuffer(IDataStream stream, ulong vcn, FolderNTFS folder) {
_folder = folder;
_clusterStart = vcn * (ulong)(_folder._record.SectorsPerCluster * _folder._record.BytesPerSector);
String magic = Util.GetASCIIString(stream, _clusterStart + 0x0, 4);
if (!magic.Equals("INDX")) {
throw new Exception("Magic INDX value not present");
}
_entriesStart = (ushort)(Util.GetUInt16(stream, _clusterStart + 0x18) + 0x18);
_entriesEnd = (ushort)(Util.GetUInt16(stream, _clusterStart + 0x1c) + _entriesStart);
ushort updateSequenceOffset = Util.GetUInt16(stream, _clusterStart + 0x04);
ushort updateSequenceLength = Util.GetUInt16(stream, _clusterStart + 0x06);
ushort updateSequenceNumber = Util.GetUInt16(stream, _clusterStart + updateSequenceOffset);
ushort[] updateSequenceArray = new ushort[updateSequenceLength - 1];
ushort read = 1;
while (read < updateSequenceLength) {
updateSequenceArray[read - 1] = Util.GetUInt16(stream, _clusterStart + updateSequenceOffset + (ushort)(read * 2));
read++;
}
_stream = new FixupStream(stream, _clusterStart, _entriesEnd, updateSequenceNumber, updateSequenceArray, (ulong)folder.BytesPerSector);
if (_entriesEnd == _entriesStart) {
throw new Exception("Entry size was 0");
}
}
示例7: ReadRegister
public byte ReadRegister(UInt16 adr)
{
switch (adr)
{
case 0x00:
return (byte)((pra | ~ddra) & 0x3f | IECLines & the_cpu_1541.IECLines);
case 0x01: return (byte)(prb | ~ddrb);
case 0x02: return ddra;
case 0x03: return ddrb;
case 0x04: return (byte)ta;
case 0x05: return (byte)(ta >> 8);
case 0x06: return (byte)tb;
case 0x07: return (byte)(tb >> 8);
case 0x08: tod_halt = false; return tod_10ths;
case 0x09: return tod_sec;
case 0x0a: return tod_min;
case 0x0b: tod_halt = true; return tod_hr;
case 0x0c: return sdr;
case 0x0d:
{
byte ret = icr; // Read and clear ICR
icr = 0;
the_cpu.ClearNMI();
return ret;
}
case 0x0e: return cra;
case 0x0f: return crb;
}
return 0; // Can't happen
}
示例8: DoPosTest
public bool DoPosTest(string testDesc, string id, UInt16 uintA, string format, String expectedValue, NumberFormatInfo _NFI)
{
bool retVal = true;
string errorDesc;
string actualValue;
TestLibrary.TestFramework.BeginScenario(testDesc);
try
{
actualValue = uintA.ToString(format, _NFI);
if (actualValue != expectedValue)
{
errorDesc =
string.Format("The string representation of {0} is not the value {1} as expected: actual({2})",
uintA, expectedValue, actualValue);
errorDesc += "\nThe format info is \"" + ((format == null) ? "null" : format) + "\" speicifed";
TestLibrary.TestFramework.LogError(id + "_001", errorDesc);
retVal = false;
}
}
catch (Exception e)
{
errorDesc = "Unexpect exception:" + e;
errorDesc += "\nThe UInt16 integer is " + uintA + ", format info is \"" + format + "\" speicifed.";
TestLibrary.TestFramework.LogError(id + "_002", errorDesc);
retVal = false;
}
return retVal;
}
示例9: wnd1
public wnd1(EndianBinaryReader er)
: base(er)
{
long basepos = er.BaseStream.Position - 0x4C;
InflationLeft = er.ReadUInt16() / 16f;
InflationRight = er.ReadUInt16() / 16f;
InflationTop = er.ReadUInt16() / 16f;
InflationBottom = er.ReadUInt16() / 16f;
FrameSizeLeft = er.ReadUInt16();
FrameSizeRight = er.ReadUInt16();
FrameSizeTop = er.ReadUInt16();
FrameSizeBottom = er.ReadUInt16();
NrFrames = er.ReadByte();
byte tmp = er.ReadByte();
UseLTMaterial = (tmp & 1) == 1;
UseVtxColorForAllWindow = (tmp & 2) == 2;
Kind = (WindowKind)((tmp >> 2) & 3);
DontDrawContent = (tmp & 8) == 16;
Padding = er.ReadUInt16();
ContentOffset = er.ReadUInt32();
FrameOffsetTableOffset = er.ReadUInt32();
er.BaseStream.Position = basepos + ContentOffset;
Content = new WindowContent(er);
er.BaseStream.Position = basepos + FrameOffsetTableOffset;
WindowFrameOffsets = er.ReadUInt32s(NrFrames);
WindowFrames = new WindowFrame[NrFrames];
for (int i = 0; i < NrFrames; i++)
{
er.BaseStream.Position = basepos + WindowFrameOffsets[i];
WindowFrames[i] = new WindowFrame(er);
}
er.BaseStream.Position = basepos + SectionSize;
}
示例10: CheckCRC
public static byte[] CheckCRC(List<byte> listdata)
{
byte[] data = ASCIItoHEX(listdata);
UInt16[] testPtr = new UInt16[data.Length];
for (int i = 0; i < data.Length; i++)
{
testPtr[i] = (UInt16)data[i];
}
UInt16 index;
UInt16 crc = 0xFFFF;
for (int i = 0; i < testPtr.Length; i++)
{
index = (UInt16)((crc ^ testPtr[i]) & 0x00FF);
crc = (UInt16)(((crc >> 8) & 0x00FF) ^ CRC_TABLE[index]);
}
if (testPtr.Length != 0)
{
crc = (UInt16)(((crc & 0x00FF) << 8) | ((crc & 0xFF00) >> 8));
}
if (crc != 0)
return null;
else
return data.Take(data.Length - 2).ToArray();
}
示例11: AddCRC
public static byte[] AddCRC(byte[] data)
{
UInt16[] testPtr = new UInt16[data.Length];
for (int i = 0; i < testPtr.Length; i++)
{
testPtr[i] = (UInt16)data[i];
}
UInt16 index;
UInt16 crc = 0xffff;
for (int i = 0; i < testPtr.Length; i++)
{
index = (UInt16)((crc ^ testPtr[i]) & 0x00ff);
crc = (UInt16)(((crc >> 8) & 0x00ff) ^ CRC_TABLE[index]);
}
if (testPtr.Length != 0)
{
crc = (UInt16)(((crc & 0x00ff) << 8) | ((crc & 0xff00) >> 8));
}
byte[] tmp = new byte[2];
tmp[0] = (byte)(((crc) >> 8) & 0x00ff);
tmp[1] = (byte)((crc) & 0x00ff);
List<byte> newdata = new List<byte>();
newdata.AddRange(data);
newdata.AddRange(tmp);
return HEXtoASCII(newdata.ToArray());
}
示例12: Readin
/// <summary>
/// 图像信息读入(+2重载)
/// </summary>
/// <param name="_fileName">文件名</param>
/// <param name="_width">图像的宽</param>
/// <param name="_height">图像的高</param>
/// <param name="_useless">无用字符消除</param>
/// <param name="_front">首行缩进</param>
/// <param name="_behind">尾行缩进</param>
/// <param name="_needDecode">需要解码</param>
/// <returns>得到的byte数组</returns>
public static byte[] Readin(String _fileName, UInt16 _width, UInt16 _height, UInt16 _useless, UInt16 _front, UInt16 _behind, Boolean _needDecode)
{
try
{
// Create an instance of StreamReader to read from a file.
// The using statement also closes the StreamReader.
using (StreamReader sr = new StreamReader(_fileName))
{
String line, info = "";
// Read and display lines from the file until the end of
// the file is reached.
while ((line = sr.ReadLine()) != null)
{
if (_useless != 0)
{
_useless--;
}
else
{
info += UsefulReadout(line, _front, _behind) + " ";
}
}
return ConvertInfo(info, _width, _height, _needDecode);
}
}
catch (Exception e)
{
// Let the user know what went wrong.
MessageSender.e = e;
return new byte[1];
}
}
示例13: ProcessFrame
public CalibratedThermalFrame ProcessFrame(ThermalFrame calibrationFrame)
{
UInt16[] output = new UInt16[Width * Height];
for(int i=0;i<output.Length;i++)
{
int v = BitConverter.ToUInt16(RawData, i * 2);
int c = BitConverter.ToUInt16(calibrationFrame.RawData, i * 2);
if (v < 0x800)
{
// Dead pixel, clamp it to zero.
v = 0;
}
else
{
v = v - c + 0x8000;
if (v < 0) v = 0;
if (v > 0xFFFF) v = 0xFFFF;
}
output[i] = (UInt16)v;
}
return new CalibratedThermalFrame(output);
}
示例14: GetBigEndian
public static UInt16 GetBigEndian(UInt16 value) {
if (BitConverter.IsLittleEndian) {
return swapByteOrder(value);
} else {
return value;
}
}
示例15: SensorInfo
public SensorInfo(RiftSharp.Win32Usb.HidCaps caps, UInt16 vendor, UInt16 product, string serial)
{
this.Capabilities = caps;
this.VendorId = vendor;
this.ProductId = product;
this.SerialNumber = serial;
}