本文整理汇总了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)));
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}