當前位置: 首頁>>代碼示例>>C#>>正文


C# UIntPtr.ToString方法代碼示例

本文整理匯總了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));
        }
開發者ID:geoffkizer,項目名稱:corefx,代碼行數:23,代碼來源:UIntPtrTests.cs

示例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()));
     }
 }
開發者ID:platatita,項目名稱:dev,代碼行數:18,代碼來源:NativeThreadProcessing.cs


注:本文中的System.UIntPtr.ToString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。