本文整理汇总了C#中System.IntPtr.CompareTo方法的典型用法代码示例。如果您正苦于以下问题:C# IntPtr.CompareTo方法的具体用法?C# IntPtr.CompareTo怎么用?C# IntPtr.CompareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IntPtr
的用法示例。
在下文中一共展示了IntPtr.CompareTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: readWriteAddressMemoryMenuItem_Click
private void readWriteAddressMemoryMenuItem_Click(object sender, EventArgs e)
{
PromptBox prompt = new PromptBox();
if (prompt.ShowDialog() == DialogResult.OK)
{
IntPtr address = new IntPtr(-1);
IntPtr regionAddress = IntPtr.Zero;
long regionSize = 0;
bool found = false;
try
{
address = ((long)BaseConverter.ToNumberParse(prompt.Value)).ToIntPtr();
}
catch
{
PhUtils.ShowError("You have entered an invalid address.");
return;
}
List<MemoryItem> items = new List<MemoryItem>();
foreach (MemoryItem item in _provider.Dictionary.Values)
items.Add(item);
items.Sort((i1, i2) => i1.Address.CompareTo(i2.Address));
int i = 0;
foreach (MemoryItem item in items)
{
MemoryItem regionItem = null;
if (item.Address.CompareTo(address) > 0)
{
if (i > 0)
regionItem = items[i - 1];
}
else if (item.Address.CompareTo(address) == 0)
{
regionItem = items[i];
}
if (regionItem != null && address.CompareTo(regionItem.Address) >= 0)
{
listMemory.Items[regionItem.Address.ToString()].Selected = true;
listMemory.Items[regionItem.Address.ToString()].EnsureVisible();
regionAddress = regionItem.Address;
regionSize = regionItem.Size;
found = true;
break;
}
i++;
}
if (!found)
{
PhUtils.ShowError("Unable to find the memory address.");
return;
}
MemoryEditor m_e = MemoryEditor.ReadWriteMemory(_pid, regionAddress, (int)regionSize, false,
new Program.MemoryEditorInvokeAction(delegate(MemoryEditor f) { f.Select(address.Decrement(regionAddress).ToInt64(), 1); }));
}
}
示例2: FIBITMAP
public void FIBITMAP()
{
FIBITMAP var = new FIBITMAP();
Assert.IsTrue(var.IsNull);
var = 41;
Assert.IsFalse(var.IsNull);
var = 0;
Assert.IsTrue(var.IsNull);
var = new IntPtr(654321);
Assert.AreEqual(654321, var);
var = IntPtr.Zero;
Assert.AreEqual(0, var);
var = 654321;
FIBITMAP compVar = var;
Assert.AreEqual(654321, compVar);
Assert.AreEqual(var, compVar);
var = 733;
compVar = 733;
Assert.AreEqual(var, compVar);
Assert.AreEqual(0, var.CompareTo(compVar));
Assert.AreEqual(0, var.CompareTo((object)compVar));
compVar = 33;
Assert.AreEqual(1, var.CompareTo(compVar));
Assert.AreEqual(1, var.CompareTo((object)compVar));
compVar = 9999;
Assert.AreEqual(-1, var.CompareTo(compVar));
Assert.AreEqual(-1, var.CompareTo((object)compVar));
var = 1000;
compVar = 1000;
Assert.IsTrue(var == compVar);
Assert.IsFalse(var != compVar);
Assert.IsTrue(var.Equals(compVar));
Assert.IsTrue(var.Equals((object)compVar));
Assert.That(var.CompareTo(compVar) == 0);
Assert.That(var.CompareTo((object)compVar) == 0);
compVar = 2000;
Assert.IsFalse(var == compVar);
Assert.IsTrue(var != compVar);
Assert.IsFalse(var.Equals(compVar));
Assert.IsFalse(var.Equals((object)compVar));
Assert.That(var.CompareTo(compVar) < 0);
Assert.That(var.CompareTo((object)compVar) < 0);
compVar = 500;
Assert.That(var.CompareTo(compVar) > 0);
Assert.That(var.CompareTo((object)compVar) > 0);
}