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


C# UnicodeEncoding.GetChars方法代码示例

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


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

示例1: PosTest3

 public void PosTest3()
 {
     Char[] srcChars = GetCharArray(10);
     Char[] desChars = new Char[10];
     Byte[] bytes = new Byte[20];
     UnicodeEncoding uEncoding = new UnicodeEncoding();
     int byteCount = uEncoding.GetBytes(srcChars, 0, 10, bytes, 0);
     int actualValue;
     actualValue = uEncoding.GetChars(bytes, 0, 0, desChars, 10);
     Assert.Equal(0, actualValue);
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:11,代码来源:UnicodeEncodingGetChars.cs

示例2: PosTest2

        public void PosTest2()
        {
            int expectedValue = _generator.GetInt16(-55) % 10 + 1;
            int actualValue;

            Char[] srcChars = GetCharArray(10);
            Char[] desChars = new Char[10];
            Byte[] bytes = new Byte[20];
            UnicodeEncoding uEncoding = new UnicodeEncoding();
            int byteCount = uEncoding.GetBytes(srcChars, 0, expectedValue, bytes, 0);

            actualValue = uEncoding.GetChars(bytes, 0, expectedValue * 2, desChars, 0);
            Assert.Equal(expectedValue, actualValue);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:14,代码来源:UnicodeEncodingGetChars.cs

示例3: NegTest2

        public void NegTest2()
        {
            Char[] srcChars = GetCharArray(10);
            Char[] desChars = new Char[10];
            Byte[] bytes = null;
            UnicodeEncoding uEncoding = new UnicodeEncoding();
            int actualValue;

            Assert.Throws<ArgumentNullException>(() =>
            {
                actualValue = uEncoding.GetChars(bytes, 0, 0, desChars, 0);
            });
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:13,代码来源:UnicodeEncodingGetChars.cs

示例4: NegTest10

        public void NegTest10()
        {
            Char[] srcChars = GetCharArray(10);
            Char[] desChars = new Char[10];
            Byte[] bytes = new Byte[20];
            UnicodeEncoding uEncoding = new UnicodeEncoding();
            int byteCount = uEncoding.GetBytes(srcChars, 0, 10, bytes, 0);
            int actualValue;

            Assert.Throws<ArgumentOutOfRangeException>(() =>
            {
                actualValue = uEncoding.GetChars(bytes, 0, 0, desChars, 11);
            });
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:14,代码来源:UnicodeEncodingGetChars.cs

示例5: PosTest1

    public bool PosTest1()
    {
        bool retVal = true;

        int expectedValue = 10;
        int actualValue;
        
        Char[] srcChars = GetCharArray(10);
        Char[] desChars = new Char[10];
        Byte[] bytes = new Byte[20];
        UnicodeEncoding uEncoding = new UnicodeEncoding();
        int byteCount = uEncoding.GetBytes(srcChars, 0, 10, bytes, 0);

        TestLibrary.TestFramework.BeginScenario("PosTest1:Invoke the method");
        try
        {
            actualValue = uEncoding.GetChars(bytes, 0, 20, desChars,0);

            if (expectedValue != actualValue)
            {
                TestLibrary.TestFramework.LogError("001", "ExpectedValue(" + expectedValue + ") !=ActualValue(" + actualValue + ")" + " when chars is :" + ToString(srcChars));
                retVal = false;
            }

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception:" + e + " when chars is :" + ToString(srcChars));
            retVal = false;
        }
        return retVal;
    }
开发者ID:l1183479157,项目名称:coreclr,代码行数:32,代码来源:unicodeencodinggetchars.cs

示例6: NegTest10

    public bool NegTest10()
    {
        bool retVal = true;

        Char[] srcChars = GetCharArray(10);
        Char[] desChars = new Char[10];
        Byte[] bytes = new Byte[20];

        UnicodeEncoding uEncoding = new UnicodeEncoding();
        int byteCount = uEncoding.GetBytes(srcChars, 0, 10, bytes, 0);

        int actualValue;

        TestLibrary.TestFramework.BeginScenario("NegTest10:Invoke the method and set charIndex as 11");
        try
        {
            actualValue = uEncoding.GetChars(bytes, 0, 0, desChars, 11);

            TestLibrary.TestFramework.LogError("023", "No ArgumentOutOfRangeException throw out expected" + " when chars is :" + ToString(srcChars));
            retVal = false;
        }
        catch (ArgumentOutOfRangeException)
        {
            //Expected Exception
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("024", "Unexpected exception:" + e + " when chars is :" + ToString(srcChars));
            retVal = false;
        }
        return retVal;
    }
开发者ID:l1183479157,项目名称:coreclr,代码行数:32,代码来源:unicodeencodinggetchars.cs

示例7: NegTest4

    public bool NegTest4()
    {
        bool retVal = true;

        Char[] srcChars = GetCharArray(10);
        Char[] desChars = new Char[10];
        Byte[] bytes = new Byte[20];

        UnicodeEncoding uEncoding = new UnicodeEncoding();
        int byteCount = uEncoding.GetBytes(srcChars, 0, 10, bytes, 0);

        int actualValue;

        TestLibrary.TestFramework.BeginScenario("NegTest4:Invoke the method and the destination buffer is not enough");
        try
        {
            actualValue = uEncoding.GetChars(bytes, 0, 20, desChars, 5);

            TestLibrary.TestFramework.LogError("011", "No ArgumentException throw out expected" + " when chars is :" + ToString(srcChars));
            retVal = false;
        }
        catch (ArgumentException)
        {

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("012", "Unexpected exception:" + e + " when chars is :" + ToString(srcChars));
            retVal = false;
        }
        return retVal;
    }
开发者ID:l1183479157,项目名称:coreclr,代码行数:32,代码来源:unicodeencodinggetchars.cs

示例8: NegTest2

    public bool NegTest2()
    {
        bool retVal = true;

        Char[] srcChars = GetCharArray(10);
        Char[] desChars = new Char[10];
        Byte[] bytes = null;

        UnicodeEncoding uEncoding = new UnicodeEncoding();
        //int byteCount = uEncoding.GetBytes(srcChars, 0, 10, bytes, 0);

        int actualValue;

        TestLibrary.TestFramework.BeginScenario("NegTest2:Invoke the method and set bytes as null");
        try
        {
            actualValue = uEncoding.GetChars(bytes, 0, 0, desChars, 0);

            TestLibrary.TestFramework.LogError("007", "No ArgumentNullException throw out expected" + " when chars is :" + ToString(srcChars));
            retVal = false;
        }
        catch (ArgumentNullException)
        {

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("008", "Unexpected exception:" + e + " when chars is :" + ToString(srcChars));
            retVal = false;
        }
        return retVal;
    }
开发者ID:l1183479157,项目名称:coreclr,代码行数:32,代码来源:unicodeencodinggetchars.cs


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