当前位置: 首页>>代码示例>>C#>>正文


C# UIntPtr.ToUInt64方法代码示例

本文整理汇总了C#中UIntPtr.ToUInt64方法的典型用法代码示例。如果您正苦于以下问题:C# UIntPtr.ToUInt64方法的具体用法?C# UIntPtr.ToUInt64怎么用?C# UIntPtr.ToUInt64使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UIntPtr的用法示例。


在下文中一共展示了UIntPtr.ToUInt64方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PosTest1

    public bool PosTest1()
    {
        bool retVal = true;

        const string c_TEST_ID = "P001";
        const string c_TEST_DESC = "PosTest1: random valid UInt64 value";
        string errorDesc;

        UIntPtr actualUIntPtr;
        bool actualResult;

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
        try
        {
            UInt64 ui = this.GetValidUInt64();
            actualUIntPtr = new UIntPtr(ui);

            actualResult = actualUIntPtr.ToUInt64() == ui;

            if (!actualResult)
            {
                errorDesc = "Actual UIntPtr value is not " + ui + " as expected: Actual(" + actualUIntPtr + ")";
                TestLibrary.TestFramework.LogError("001" + " TestId-" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            errorDesc = "Unexpected exception: " + e;
            TestLibrary.TestFramework.LogError("002" + " TestId-" + c_TEST_ID, errorDesc);
            retVal = false;
        }

        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:35,代码来源:uintptrctor_uint64.cs

示例2: 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:kkurni,项目名称:corefx,代码行数:23,代码来源:UIntPtr.cs

示例3: TestPointer

    private static void TestPointer(UIntPtr p, ulong expected)
    {
        ulong l = p.ToUInt64();
        Assert.Equal(expected, l);

        uint expected32 = (uint)expected;
        if (expected32 != expected)
        {
            Assert.Throws<OverflowException>(() => p.ToUInt32());
            return;
        }

        {
            uint i = p.ToUInt32();
            Assert.Equal(expected32, i);
        }

        string s = p.ToString();
        string sExpected = expected.ToString();
        Assert.Equal(s, sExpected);

        Assert.True(p == new UIntPtr(expected));
        Assert.Equal(p, new UIntPtr(expected));
        Assert.False(p == new UIntPtr(expected + 1));
        Assert.NotEqual(p, new UIntPtr(expected + 1));
        Assert.False(p != new UIntPtr(expected));
        Assert.True(p != new UIntPtr(expected + 1));
    }
开发者ID:noahfalk,项目名称:corefx,代码行数:28,代码来源:UIntPtr.cs

示例4: PosTest2

    public bool PosTest2()
    {
        bool retVal = true;

        const string c_TEST_ID = "P002";
        const string c_TEST_DESC = "PosTest2: UIntPtr with a random value between 0 and UInt32.MaxValue";
        string errorDesc;

        UInt64 actualUI, expectedUI;
        UIntPtr uiPtr;
        bool actualResult;

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
        try
        {
            expectedUI = this.GetUInt64() % ((UInt64)UInt32.MaxValue + 1);
            uiPtr = new UIntPtr(expectedUI);
            actualUI = uiPtr.ToUInt64();

            actualResult = actualUI == expectedUI;
            if (!actualResult)
            {
                errorDesc = "Actual UInt32 from UIntPtr is not " + expectedUI + " as expected: Actual(" + actualUI + ")";
                TestLibrary.TestFramework.LogError("003" + " TestId-" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            errorDesc = "Unexpected exception: " + e;
            TestLibrary.TestFramework.LogError("004" + " TestId-" + c_TEST_ID, errorDesc);
            retVal = false;
        }

        return retVal;
    }
开发者ID:l1183479157,项目名称:coreclr,代码行数:36,代码来源:uintptrtouint64.cs

示例5: runTest

 public virtual bool runTest()
   {
   Console.Error.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
   int iCountErrors = 0;
   int iCountTestcases = 0;
   String strLoc = "Loc_000oo";
   UInt64 lValue;
   UIntPtr ip1;
   try {
   strLoc = "Loc_743wg";
   lValue = 16;
   ip1 = new UIntPtr(lValue);
   iCountTestcases++;
   if(ip1.ToUInt64() != lValue){
   iCountErrors++;
   Console.WriteLine("Err_2975sf! Wrong value returned");
   }
   strLoc = "Loc_0084wf";
   lValue = 0;
   ip1 = new UIntPtr(lValue);
   iCountTestcases++;
   if(ip1.ToUInt64() != UIntPtr.Zero.ToUInt64()){
   iCountErrors++;
   Console.WriteLine("Err_974325sdg! Wrong value returned");
   }
   strLoc = "Loc_93476sdg";
   lValue = UInt32.MaxValue;
   ip1 = new UIntPtr(lValue);
   iCountTestcases++;
   if(ip1.ToUInt64() != lValue){
   iCountErrors++;
   Console.WriteLine("Err_07536tsg! Wrong value returned");
   }
   lValue = UInt32.MinValue;
   ip1 = new UIntPtr(lValue);
   if(ip1.ToUInt64() != lValue){
   iCountErrors++;
   Console.WriteLine("Err_9875wrsg! Wrong value returned");
   }
   strLoc = "Loc_8745sdg";
   lValue = UInt64.MaxValue;
   iCountTestcases++;
   try{
   ip1 = new UIntPtr(lValue);
   iCountErrors++;
   Console.WriteLine("Err_874325sdg! No oexception thrown. Is this a 64 bit machine? or has the functionality changed?");
   }catch(OverflowException){
   }catch(Exception ex){
   iCountErrors++;
   Console.WriteLine("Err_82375d! Wrong Exception returned, " + ex.GetType().Name);
   }
   lValue = UInt64.MinValue;
   ip1 = new UIntPtr(lValue);
   if(ip1.ToUInt64() != lValue){
   iCountErrors++;
   Console.WriteLine("Err_87453wg! Wrong value returned");
   }             
   } catch (Exception exc_general ) {
   ++iCountErrors;
   Console.WriteLine(s_strTFAbbrev +" Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general=="+exc_general);
   }
   if ( iCountErrors == 0 )
     {
     Console.Error.WriteLine( "paSs.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
     return true;
     }
   else
     {
     Console.Error.WriteLine("FAiL!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
     return false;
     }
   }
开发者ID:ArildF,项目名称:masters,代码行数:72,代码来源:co8535ctor_ulong.cs

示例6: PosTest3

    public bool PosTest3()
    {
        bool retVal = true;

        const string c_TEST_ID = "P003";
        string testDesc = string.Format("PosTest3: value is UInt{0}.MaxValue", 8 * UIntPtr.Size);

        string errorDesc;

        UIntPtr actualUIntPtr;
        bool actualResult;

        TestLibrary.TestFramework.BeginScenario(testDesc);
        try
        {
            UInt64 ui = (UIntPtr.Size == 4) ? UInt32.MaxValue : UInt64.MaxValue;
            actualUIntPtr = new UIntPtr(ui);

            actualResult = actualUIntPtr.ToUInt64() == ui;

            if (!actualResult)
            {
                errorDesc = "Actual UIntPtr value is not " + ui + " as expected: Actual(" + actualUIntPtr + ")";
                TestLibrary.TestFramework.LogError("005" + " TestId-" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            errorDesc = "Unexpected exception: " + e;
            TestLibrary.TestFramework.LogError("006" + " TestId-" + c_TEST_ID, errorDesc);
            retVal = false;
        }

        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:36,代码来源:uintptrctor_uint64.cs

示例7: TestPointer

    private static void TestPointer(UIntPtr p, ulong expected)
    {
        ulong l = p.ToUInt64();
        Assert.Equal(l, expected);

        uint expected32 = (uint)expected;
        if (expected32 != expected)
        {
            try
            {
                uint i = p.ToUInt32();
                Assert.True(false, "ToUInt32() should have thrown.");
            }
            catch (OverflowException)
            {
            }
            return;
        }

        {
            uint i = p.ToUInt32();
            Assert.Equal(i, expected32);
        }

        String s = p.ToString();
        String sExpected = expected.ToString();
        Assert.Equal(s, sExpected);

        bool b;

        b = (p == new UIntPtr(expected));
        Assert.True(b);

        b = (p == new UIntPtr(expected + 1));
        Assert.False(b);

        b = (p != new UIntPtr(expected));
        Assert.False(b);

        b = (p != new UIntPtr(expected + 1));
        Assert.True(b);
    }
开发者ID:johnhhm,项目名称:corefx,代码行数:42,代码来源:UIntPtr.cs


注:本文中的UIntPtr.ToUInt64方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。