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


C# MutableString.SetChar方法代码示例

本文整理汇总了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;
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:11,代码来源:MutableStringOps.cs

示例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;
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:27,代码来源:MutableStringOps.cs

示例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;
 }
开发者ID:,项目名称:,代码行数:8,代码来源:

示例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);
     }
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:28,代码来源:MutableStringOps.cs

示例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;
 }
开发者ID:jcteague,项目名称:ironruby,代码行数:7,代码来源:Glob.cs


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