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


C# String.CopyTo方法代码示例

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


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

示例1: TypeLexer

 public TypeLexer(String s)
 {
     // Turn the string into a char array with a NUL terminator.
     char[] chars = new char[s.Length + 1];
     s.CopyTo(0, chars, 0, s.Length);
     _chars = chars;
     _index = 0;
 }
开发者ID:noahfalk,项目名称:corert,代码行数:8,代码来源:TypeLexer.cs

示例2: AssemblyNameLexer

 internal AssemblyNameLexer(String s)
 {
     // Convert string to char[] with NUL terminator. (An actual NUL terminator in the input string will be treated
     // as an actual end of string: this is compatible with desktop behavior.)
     char[] chars = new char[s.Length + 1];
     s.CopyTo(0, chars, 0, s.Length);
     _chars = chars;
     _index = 0;
 }
开发者ID:noahfalk,项目名称:corert,代码行数:9,代码来源:AssemblyNameLexer.cs

示例3: WriteAsyncInternal

        // We pass in private instance fields of this MarshalByRefObject-derived type as local params
        // to ensure performant access inside the state machine that corresponds this async method.
        // Fields that are written to must be assigned at the end of the method *and* before instance invocations.
        private static async Task WriteAsyncInternal(StreamWriter _this, String value,
                                                     Char[] charBuffer, Int32 charPos, Int32 charLen, Char[] coreNewLine,
                                                     bool autoFlush, bool appendNewLine)
        {
            Contract.Requires(value != null);

            int count = value.Length;
            int index = 0;

            while (count > 0)
            {
                if (charPos == charLen) {
                    await _this.FlushAsyncInternal(false, false, charBuffer, charPos).ConfigureAwait(false);
                    Debug.Assert(_this.charPos == 0);
                    charPos = 0;
                }

                int n = charLen - charPos;
                if (n > count)
                    n = count;

                Debug.Assert(n > 0, "StreamWriter::Write(String) isn't making progress!  This is most likely a race condition in user code.");

                value.CopyTo(index, charBuffer, charPos, n);

                charPos += n;
                index += n;
                count -= n;
            }

            if (appendNewLine)
            {
                for (Int32 i = 0; i < coreNewLine.Length; i++)   // Expect 2 iterations, no point calling BlockCopy
                {
                    if (charPos == charLen) {
                        await _this.FlushAsyncInternal(false, false, charBuffer, charPos).ConfigureAwait(false);
                        Debug.Assert(_this.charPos == 0);
                        charPos = 0;
                    }

                    charBuffer[charPos] = coreNewLine[i];
                    charPos++;
                }
            }

            if (autoFlush) {
                await _this.FlushAsyncInternal(true, false, charBuffer, charPos).ConfigureAwait(false);
                Debug.Assert(_this.charPos == 0);
                charPos = 0;
            }

            _this.CharPos_Prop = charPos;
        }
开发者ID:kouvel,项目名称:coreclr,代码行数:56,代码来源:StreamWriter.cs

示例4: Write

        public override void Write(String value)
        {
            if (value != null)
            {

                CheckAsyncTaskInProgress();

                int count = value.Length;
                int index = 0;
                while (count > 0) {
                    if (charPos == charLen) Flush(false, false);
                    int n = charLen - charPos;
                    if (n > count) n = count;
                    Debug.Assert(n > 0, "StreamWriter::Write(String) isn't making progress!  This is most likely a race condition in user code.");
                    value.CopyTo(index, charBuffer, charPos, n);
                    charPos += n;
                    index += n;
                    count -= n;
                }
                if (autoFlush) Flush(true, false);
            }
        }
开发者ID:kouvel,项目名称:coreclr,代码行数:22,代码来源:StreamWriter.cs

示例5: Append

    internal void Append(String s) {
        int l = s.Length;
        int newFreePos = _freePos + l;

        if (newFreePos > _size)
            Grow(newFreePos);

        s.CopyTo(0, _charBuffer, _freePos, l);
        _freePos = newFreePos;
    }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:10,代码来源:ISAPIWorkerRequest.cs

示例6: Write

        public override void Write(String s) {
            int len = s.Length;
            int newFreePos = _freePos + len;

            if (newFreePos > _size)
                Grow(newFreePos);

            s.CopyTo(0, _charBuffer, _freePos, len);
            _freePos = newFreePos;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:10,代码来源:LosWriter.cs


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