bluetoothaddress.cs
来自「Windows Mobile的蓝牙C#程序」· CS 代码 · 共 62 行
CS
62 行
#region Using 指令
using System;
#endregion
namespace OpenNETCF.Net.Bluetooth {
/// <summary>
/// BluetoothAddress 的摘要说明。
/// </summary>
public sealed class BluetoothAddress : IComparable {
private byte[] data;
public const int Giac = 0x9e8b33;
internal const int IacFirst = 0x9e8b00;
internal const int IacLast = 0x9e8b3f;
public const int Liac = 0x9e8b00;
public static readonly BluetoothAddress None = new BluetoothAddress();
static BluetoothAddress() {
None = new BluetoothAddress();
}
internal BluetoothAddress() {
this.data = new byte[8];
}
public BluetoothAddress(byte[] address) : this() {
if (address.Length != 6) {
throw new ArgumentException("address");
}
Buffer.BlockCopy(address, 0, this.data, 0, 6);
}
public BluetoothAddress(long address) : this() {
BitConverter.GetBytes(address).CopyTo(this.data, 0);
}
#region IComparable 成员
int IComparable.CompareTo(object obj) {
BluetoothAddress address = obj as BluetoothAddress;
if (address != null) {
return this.ToInt64().CompareTo(address.ToInt64());
}
return -1;
}
#endregion
public long ToInt64() {
return BitConverter.ToInt64(this.data, 0);
}
public byte[] ToByteArray() {
return this.data;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?