本文整理匯總了C#中System.UIntPtr.ToString方法的典型用法代碼示例。如果您正苦於以下問題:C# UIntPtr.ToString方法的具體用法?C# UIntPtr.ToString怎麽用?C# UIntPtr.ToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.UIntPtr
的用法示例。
在下文中一共展示了UIntPtr.ToString方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: VerifyPointer
private static void VerifyPointer(UIntPtr ptr, ulong expected)
{
Assert.Equal(expected, ptr.ToUInt64());
uint expected32 = (uint)expected;
if (expected32 != expected)
{
Assert.Throws<OverflowException>(() => ptr.ToUInt32());
return;
}
Assert.Equal(expected32, ptr.ToUInt32());
Assert.Equal(expected.ToString(), ptr.ToString());
Assert.Equal(ptr, new UIntPtr(expected));
Assert.True(ptr == new UIntPtr(expected));
Assert.False(ptr != new UIntPtr(expected));
Assert.NotEqual(ptr, new UIntPtr(expected + 1));
Assert.False(ptr == new UIntPtr(expected + 1));
Assert.True(ptr != new UIntPtr(expected + 1));
}
示例2: SetThreadAffinity
private void SetThreadAffinity(int threadIndex, IntPtr hThread)
{
UIntPtr newThreadAffinity = new UIntPtr((uint)threadIndex + 1);
uint result = Native.SetThreadAffinityMask(hThread, newThreadAffinity);
if (result == 0)
{
int errorCode = Marshal.GetLastWin32Error();
Log(string.Format("Thread affinity setting failed. New: {0}, Win32Error: {1}",
newThreadAffinity.ToString(),
errorCode));
}
else
{
Log(string.Format("Thread affinity setting succeeded. Previouse: {0}, New: {1}",
result,
newThreadAffinity.ToString()));
}
}