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


C# MutableString.Insert方法代码示例

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


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

示例1: IncrementChar

 public static void IncrementChar(MutableString/*!*/ str, int index) {
     byte c = str.GetByte(index);
     if (c == 255) {
         str.SetByte(index, 0);
         if (index > 0) {
             IncrementChar(str, index - 1);
         } else {
             str.Insert(0, 1);
         }
     } else {
         str.SetByte(index, unchecked((byte)(c + 1)));
     }
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:13,代码来源:MutableStringOps.cs

示例2: Insert

        public static MutableString Insert(MutableString/*!*/ self, [DefaultProtocol]int start, [DefaultProtocol, NotNull]MutableString/*!*/ value) {
            int offset = start < 0 ? start + self.Length + 1 : start;
            if (offset > self.Length || offset < 0) {
                throw RubyExceptions.CreateIndexError(String.Format("index {0} out of string", start));
            }

            return self.Insert(offset, value).TaintBy(value);
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:8,代码来源:MutableStringOps.cs

示例3: IncrementAlphaNumericChar

 // TODO: remove recursion
 public static void IncrementAlphaNumericChar(MutableString/*!*/ str, int index) {
     char c = str.GetChar(index);
     if (c == 'z' || c == 'Z' || c == '9') {
         int nextIndex = GetIndexOfRightmostAlphaNumericCharacter(str, index - 1);
         if (c == 'z') {
             str.SetChar(index, 'a');
             if (nextIndex == -1)
                 str.Insert(index, "a");
             else
                 IncrementAlphaNumericChar(str, nextIndex);
         } else if (c == 'Z') {
             str.SetChar(index, 'A');
             if (nextIndex == -1)
                 str.Insert(index, "A");
             else
                 IncrementAlphaNumericChar(str, nextIndex);
         } else {
             str.SetChar(index, '0');
             if (nextIndex == -1)
                 str.Insert(index, "1");
             else
                 IncrementAlphaNumericChar(str, nextIndex);
         }
     } else {
         IncrementChar(str, index);
     }
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:28,代码来源:MutableStringOps.cs

示例4: Insert

 public static MutableString Insert(MutableString/*!*/ self, [DefaultProtocol]int start, [DefaultProtocol, NotNull]MutableString/*!*/ value) {
     return self.Insert(NormalizeInsertIndex(start, self.GetLength()), value).TaintBy(value);
 }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:3,代码来源:MutableStringOps.cs

示例5: op_Insert_int_string

        public void op_Insert_int_string(string expected,
                                         string text,
                                         int index,
                                         string value)
        {
            var actual = new MutableString(text);

            Assert.Same(actual, actual.Insert(index, value ?? string.Empty));

            Assert.Equal(new MutableString(expected), actual);
        }
开发者ID:KarlDirck,项目名称:cavity,代码行数:11,代码来源:MutableString.Facts.cs

示例6: op_Insert_int_char_whenDefault

        public void op_Insert_int_char_whenDefault()
        {
            var expected = new MutableString("Ex");
            var actual = new MutableString();

            Assert.Same(actual, actual.Insert(0, 'x'));
            Assert.Same(actual, actual.Insert(0, 'E'));

            Assert.Equal(expected, actual);
        }
开发者ID:KarlDirck,项目名称:cavity,代码行数:10,代码来源:MutableString.Facts.cs

示例7: op_Insert_int_char

        public void op_Insert_int_char()
        {
            var expected = new MutableString("Example");
            var actual = new MutableString("ample");

            Assert.Same(actual, actual.Insert(0, 'x'));
            Assert.Same(actual, actual.Insert(0, 'E'));

            Assert.Equal(expected, actual);
        }
开发者ID:KarlDirck,项目名称:cavity,代码行数:10,代码来源:MutableString.Facts.cs

示例8: op_Insert_int_IEnumerableOfChar

        public void op_Insert_int_IEnumerableOfChar(string expected,
                                                    string text,
                                                    int index,
                                                    string value)
        {
            var actual = new MutableString(text);

            Assert.Same(actual, actual.Insert(index, (value ?? string.Empty).ToCharArray()));

            Assert.Equal(new MutableString(expected), actual);
        }
开发者ID:KarlDirck,项目名称:cavity,代码行数:11,代码来源:MutableString.Facts.cs


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