本文整理汇总了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()));
}
}