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


C# ASCIIEncoding.GetByteCount方法代码示例

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


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

示例1: DoPosTest

 private void DoPosTest(string source, int expectedValue)
 {
     ASCIIEncoding ascii;
     int actualValue;
     ascii = new ASCIIEncoding();
     actualValue = ascii.GetByteCount(source);
     Assert.Equal(expectedValue, actualValue);
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:8,代码来源:ASCIIEncodingGetByteCount1.cs

示例2: DoPosTest

        private void DoPosTest(char[] chars, int startIndex, int count, int expectedValue)
        {
            ASCIIEncoding ascii;
            int actualValue;

            ascii = new ASCIIEncoding();
            actualValue = ascii.GetByteCount(chars, startIndex, count);
            Assert.Equal(expectedValue, actualValue);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:9,代码来源:ASCIIEncodingGetByteCount2.cs

示例3: NegTest1

 public void NegTest1()
 {
     ASCIIEncoding ascii;
     string source = null;
     ascii = new ASCIIEncoding();
     Assert.Throws<ArgumentNullException>(() =>
     {
         ascii.GetByteCount(source);
     });
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:10,代码来源:ASCIIEncodingGetByteCount1.cs

示例4: NegTest1

        public void NegTest1()
        {
            ASCIIEncoding ascii;
            char[] chars = null;

            ascii = new ASCIIEncoding();
            Assert.Throws<ArgumentNullException>(() =>
            {
                ascii.GetByteCount(chars, 0, 0);
            });
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:11,代码来源:ASCIIEncodingGetByteCount2.cs

示例5: PosTest2

        public void PosTest2()
        {
            ASCIIEncoding ascii;
            byte[] bytes;
            int byteIndex, byteCount;
            char[] chars;
            int charIndex;
            string source;

            ascii = new ASCIIEncoding();
            source = _generator.GetString(-55, false, c_MIN_STRING_LENGTH, c_MAX_STRING_LENGTH);
            bytes = new byte[ascii.GetByteCount(source)];
            ascii.GetBytes(source, 0, source.Length, bytes, 0);
            byteIndex = _generator.GetInt32(-55) % bytes.Length;
            byteCount = _generator.GetInt32(-55) % (bytes.Length - byteIndex) + 1;
            chars = new char[byteCount + _generator.GetInt32(-55) % c_MAX_STRING_LENGTH];
            charIndex = _generator.GetInt32(-55) % (chars.Length - byteCount + 1);

            DoPosTest(ascii, bytes, byteIndex, byteCount, chars, charIndex);
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:20,代码来源:ASCIIEncodingGetChars.cs

示例6: PosTest2

        public void PosTest2()
        {
            ASCIIEncoding ascii;
            char[] chars;
            int charIndex, count;
            byte[] bytes;
            int byteIndex;

            ascii = new ASCIIEncoding();
            InitializeCharacterArray(out chars);
            charIndex = _generator.GetInt32(-55) % chars.Length;
            count = _generator.GetInt32(-55) % (chars.Length - charIndex) + 1;

            int minLength = ascii.GetByteCount(chars, charIndex, count);
            int length = minLength + _generator.GetInt32(-55) % (Int16.MaxValue - minLength);
            bytes = new byte[length];
            for (int i = 0; i < bytes.Length; ++i)
            {
                bytes[i] = 0;
            }
            byteIndex = _generator.GetInt32(-55) % (bytes.Length - minLength + 1);

            DoPosTest(ascii, chars, charIndex, count, bytes, byteIndex);
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:24,代码来源:ASCIIEncodingGetBytes2.cs

示例7: PosTest2

        public void PosTest2()
        {
            ASCIIEncoding ascii;
            string source;
            int charIndex, count;
            byte[] bytes;
            int byteIndex;

            ascii = new ASCIIEncoding();
            source = _generator.GetString(-55, false, c_MIN_STRING_LENGTH, c_MAX_STRING_LENGTH);
            charIndex = _generator.GetInt32(-55) % source.Length;
            count = _generator.GetInt32(-55) % (source.Length - charIndex) + 1;

            int minLength = ascii.GetByteCount(source.Substring(charIndex, count));
            int length = minLength + _generator.GetInt32(-55) % (Int16.MaxValue - minLength);
            bytes = new byte[length];
            for (int i = 0; i < bytes.Length; ++i)
            {
                bytes[i] = 0;
            }
            byteIndex = _generator.GetInt32(-55) % (bytes.Length - minLength + 1);

            DoPosTest(ascii, source, charIndex, count, bytes, byteIndex);
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:24,代码来源:ASCIIEncodingGetBytes1.cs

示例8: DoNegAOORTest

 private void DoNegAOORTest(char[] chars, int startIndex, int count)
 {
     ASCIIEncoding ascii = new ASCIIEncoding();
     Assert.Throws<ArgumentOutOfRangeException>(() =>
    {
        ascii.GetByteCount(chars, startIndex, count);
    });
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:8,代码来源:ASCIIEncodingGetByteCount2.cs

示例9: NegTest8

        public void NegTest8()
        {
            ASCIIEncoding ascii;
            char[] chars;
            int charIndex, count;
            byte[] bytes;
            int byteIndex;

            ascii = new ASCIIEncoding();
            InitializeCharacterArray(out chars);
            charIndex = _generator.GetInt32(-55) % chars.Length;
            count = _generator.GetInt32(-55) % (chars.Length - charIndex) + 1;
            int minLength = ascii.GetByteCount(chars, charIndex, count);
            bytes = new byte[_generator.GetInt32(-55) % minLength];
            byteIndex = 0;

            Assert.Throws<ArgumentException>(() =>
            {
                ascii.GetBytes(chars, charIndex, count, bytes, byteIndex);
            });
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:21,代码来源:ASCIIEncodingGetBytes2.cs

示例10: NegTest7

        public void NegTest7()
        {
            ASCIIEncoding ascii;
            char[] chars;
            int charIndex, count;
            byte[] bytes;
            int byteIndex;

            ascii = new ASCIIEncoding();
            InitializeCharacterArray(out chars);
            charIndex = _generator.GetInt32(-55) % chars.Length;
            count = _generator.GetInt32(-55) % (chars.Length - charIndex) + 1;
            int minLength = ascii.GetByteCount(chars, charIndex, count);
            bytes = new byte[minLength];
            byteIndex = bytes.Length + _generator.GetInt32(-55) % (int.MaxValue - bytes.Length);

            DoNegAOORTest(ascii, chars, charIndex, count, bytes, byteIndex);
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:18,代码来源:ASCIIEncodingGetBytes2.cs

示例11: NegTest8

        public void NegTest8()
        {
            ASCIIEncoding ascii;
            string source;
            int charIndex, count;
            byte[] bytes;
            int byteIndex;

            ascii = new ASCIIEncoding();
            source = _generator.GetString(-55, false, c_MIN_STRING_LENGTH, c_MAX_STRING_LENGTH);
            charIndex = _generator.GetInt32(-55) % source.Length;
            count = _generator.GetInt32(-55) % (source.Length - charIndex) + 1;
            int minLength = ascii.GetByteCount(source.Substring(charIndex, count));
            bytes = new byte[_generator.GetInt32(-55) % minLength];
            byteIndex = 0;

            Assert.Throws<ArgumentException>(() =>
           {
               ascii.GetBytes(source, charIndex, count, bytes, byteIndex);
           });
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:21,代码来源:ASCIIEncodingGetBytes1.cs

示例12: NegTest7

        public void NegTest7()
        {
            ASCIIEncoding ascii;
            string source;
            int charIndex, count;
            byte[] bytes;
            int byteIndex;

            ascii = new ASCIIEncoding();
            source = _generator.GetString(-55, false, c_MIN_STRING_LENGTH, c_MAX_STRING_LENGTH);
            charIndex = _generator.GetInt32(-55) % source.Length;
            count = _generator.GetInt32(-55) % (source.Length - charIndex) + 1;
            int minLength = ascii.GetByteCount(source.Substring(charIndex, count));
            bytes = new byte[minLength];
            byteIndex = bytes.Length + _generator.GetInt32(-55) % (int.MaxValue - bytes.Length);

            DoNegAOORTest(ascii, source, charIndex, count, bytes, byteIndex);
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:18,代码来源:ASCIIEncodingGetBytes1.cs


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