本文整理汇总了C#中Oid.ToByteArray方法的典型用法代码示例。如果您正苦于以下问题:C# Oid.ToByteArray方法的具体用法?C# Oid.ToByteArray怎么用?C# Oid.ToByteArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oid
的用法示例。
在下文中一共展示了Oid.ToByteArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompareTo
/// <summary>
/// Compares the current object with another object of the same type.
/// </summary>
/// <param name = "other">An object to compare with this object.</param>
/// <returns>
/// A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has the following meanings:
/// Value
/// Meaning
/// Less than zero
/// This object is less than the <paramref name = "other" /> parameter.
/// Zero
/// This object is equal to <paramref name = "other" />.
/// Greater than zero
/// This object is greater than <paramref name = "other" />.
/// </returns>
public int CompareTo(Oid other)
{
if(ReferenceEquals(other, null))
return 1;
var otherBytes = other.ToByteArray();
for(var x = 0; x < _bytes.Length; x++)
if(_bytes[x] < otherBytes[x])
return -1;
else if(_bytes[x] > otherBytes[x])
return 1;
return 0;
}
示例2: Write
/// <summary>
/// Writes the specified id.
/// </summary>
/// <param name = "id">The id.</param>
private void Write(Oid id)
{
_writer.Write(id.ToByteArray());
}
示例3: TestToByteArray
public void TestToByteArray()
{
var bytes = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
var bval = new Oid(bytes);
var bytes2 = bval.ToByteArray();
Assert.IsNotNull(bytes2);
Assert.AreEqual(12, bytes2.Length);
Assert.AreEqual(bytes, bytes2);
}