本文整理汇总了C#中MutableString.SetChar方法的典型用法代码示例。如果您正苦于以下问题:C# MutableString.SetChar方法的具体用法?C# MutableString.SetChar怎么用?C# MutableString.SetChar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MutableString
的用法示例。
在下文中一共展示了MutableString.SetChar方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SwapCaseChar
public static bool SwapCaseChar(MutableString/*!*/ self, int index) {
char current = self.GetChar(index);
if (current >= 'A' && current <= 'Z') {
self.SetChar(index, Char.ToLower(current));
return true;
} else if (current >= 'a' && current <= 'z') {
self.SetChar(index, Char.ToUpper(current));
return true;
}
return false;
}
示例2: SqueezeMutableString
private static MutableString SqueezeMutableString(MutableString/*!*/ str, MutableString[]/*!*/ ranges) {
// if squeezeAll is true then there should be no ranges, and vice versa
Assert.NotNull(str, ranges);
// convert the args into a map of characters to be squeezed (same algorithm as count)
BitArray map = null;
if (ranges.Length > 0) {
map = new RangeParser(ranges).Parse();
}
// Do the squeeze in place
int j = 1, k = 1;
while (j < str.Length) {
if (str.GetChar(j) == str.GetChar(j-1) && (ranges.Length == 0 || map.Get(str.GetChar(j)))) {
j++;
} else {
str.SetChar(k, str.GetChar(j));
j++; k++;
}
}
if (j > k) {
str.Remove(k, j - k);
}
// if not modified return null
return j == k ? null : str;
}
示例3: DownCaseChar
public static bool DownCaseChar(MutableString/*!*/ self, int index) {
char current = self.GetChar(index);
if (current >= 'A' && current <= 'Z') {
self.SetChar(index, current.ToLowerInvariant());
return true;
}
return false;
}
示例4: 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);
}
}
示例5: CanonicalizePath
public static MutableString/*!*/ CanonicalizePath(MutableString/*!*/ path) {
for (int i = 0; i < path.Length; i++) {
if (path.GetChar(i) == '\\')
path.SetChar(i, '/');
}
return path;
}