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


C# UIntPtr.ToString方法代码示例

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


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

示例1: 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";
   UInt32 iValue;
   UIntPtr ip1;
   try {
   strLoc = "Loc_743wg";
   iValue = 16;
   ip1 = new UIntPtr(iValue);
   iCountTestcases++;
   if(ip1.ToString() != iValue.ToString()){
   iCountErrors++;
   Console.WriteLine("Err_2975sf! Wrong value returned");
   }
   strLoc = "Loc_0084wf";
   iValue = 0;
   ip1 = new UIntPtr(iValue);
   iCountTestcases++;
   if(ip1.ToString() != iValue.ToString()){
   iCountErrors++;
   Console.WriteLine("Err_974325sdg! Wrong value returned");
   }
   strLoc = "Loc_93476sdg";
   iValue = UInt32.MaxValue;
   ip1 = new UIntPtr(iValue);
   iCountTestcases++;
   if(ip1.ToString() != iValue.ToString()){
   iCountErrors++;
   Console.WriteLine("Err_07536tsg! Wrong value returned");
   }
   iValue = UInt32.MinValue;
   ip1 = new UIntPtr(iValue);
   if(ip1.ToString() != iValue.ToString()){
   iCountErrors++;
   Console.WriteLine("Err_9875wrsg! 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,代码行数:54,代码来源:co8542tostring.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 Int32 value ";
        string errorDesc;

        string actualStr, expectedStr;
        UIntPtr uiPtr;
        bool actualResult;

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
        try
        {
            UInt32 ui = (UInt32)TestLibrary.Generator.GetInt32(-55);
            expectedStr = (UIntPtr.Size == 4) ? ui.ToString() : ((UInt64)ui).ToString();
            uiPtr = new UIntPtr(ui);
            actualStr = uiPtr.ToString();

            actualResult = actualStr == expectedStr;
            if (!actualResult)
            {
                errorDesc = "Actual string from UIntPtr is not " + expectedStr + " as expected: Actual(" + actualStr + ")";
                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:CheneyWu,项目名称:coreclr,代码行数:37,代码来源:uintptrtostring.cs

示例5: PosTest4

    public bool PosTest4()
    {
        bool retVal = true;

        const string c_TEST_ID = "P004";
        string testDesc = string.Format("PosTest4: value is max {0}-bit pointer: UInt{0}.MaxValue",
                                                      8 * UIntPtr.Size);
        string errorDesc;

        string actualStr, expectedStr;
        UIntPtr uiPtr;
        bool actualResult;

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

            actualResult = actualStr == expectedStr;
            if (!actualResult)
            {
                errorDesc = "Actual hash code is not " + expectedStr + " as expected: Actual(" + actualStr + ")";
                TestLibrary.TestFramework.LogError("007" + " TestId-" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            errorDesc = "Unexpected exception: " + e;
            TestLibrary.TestFramework.LogError("008" + " TestId-" + c_TEST_ID, errorDesc);
            retVal = false;
        }

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

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