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


C# StringBuffer.Delete方法代码示例

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


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

示例1: dump

        public static string dump(byte[] abyte0, int beginIndex, int endIndex, bool spaceFlag, bool asciiFlag, bool lineNumberFlag, int linenumber)
        {
            byte[] cont = abyte0;
            if(abyte0 == null || cont.Length  == 0)
                return "";

            string outMsg = "";
            int totalLine = (endIndex - beginIndex) / 16;
            int lineNumber, q;
            int offset = beginIndex;
            byte byte0;
            StringBuffer stringbuffer = new StringBuffer(6 + (spaceFlag?48:32));
            StringBuffer asciibuffer = new StringBuffer();
            string printString;
            int stringcount;
            int asccicount;

            if (linenumber < 0)
                linenumber = 0;
            else
                linenumber = linenumber % 10000;

            for(int i = 0; i <= totalLine; i++, linenumber++)
            {
                if (offset < endIndex) {
                    stringcount = stringbuffer.Length();
                    asccicount = asciibuffer.Length();
                    stringbuffer.Delete(0, stringcount);
                    asciibuffer.Delete(0, asccicount);
                    if (lineNumberFlag) {
                        stringbuffer.Append("0000: ");
                        lineNumber = linenumber;
                        for(byte0 = 3; byte0 >=0; byte0--){
                            q = (lineNumber * 52429) >> (16+3);
                            stringbuffer.SetCharAt(byte0, toHexChar(lineNumber - ((q << 3) + (q << 1)))); // toHexChar(lineNumber-(q*10))
                            lineNumber = q;
                            if (0 == lineNumber) break;
                        }
                    }
                    for(int j = 0; j < 16; j++, offset++)
                    {
                        if (offset < endIndex) {
                            byte0 = abyte0[offset];
                            stringbuffer.Append(toHexChar(byte0 >> 4));
                            stringbuffer.Append(toHexChar(byte0));
                            if (spaceFlag)
                                stringbuffer.Append(' ');
                            if (asciiFlag) {
                                if (byte0 >= 0x20 && byte0 <= 0x7E)
                                    asciibuffer.Append((char)byte0);
                                else
                                    asciibuffer.Append('.');
                            }
                        } else {
                            stringbuffer.Append(' ');
                            stringbuffer.Append(' ');
                            if (spaceFlag)
                                stringbuffer.Append(' ');
                        }
                    }
                    if (asciiFlag)
                        printString = stringbuffer.ToString() + "; " + asciibuffer.ToString();
                    else
                        printString = stringbuffer.ToString();
                    //        printLine(printString);
                    outMsg =  outMsg + printString + "\n";
                } else {
                    break;
                }
            }
            printString = null;
            stringbuffer = asciibuffer = null;
            return outMsg;
        }
开发者ID:Coopermine,项目名称:P25M_PRINTER,代码行数:74,代码来源:Tracer.cs

示例2: seperateStr

        /**
         * Seperate String with str token
         *
         * @param str - the string which will be cut
         * @return cut string array
         */
        // @SuppressWarnings("unused")
        private static string[] seperateStr(string str)
        {
            bool doubleSpace = false;
            int wordCount = 0;
            StringBuffer sb = new StringBuffer();
            if (str == null || str.Length == 0)
            {
                return null;
            }
            for (int j = 0; j < str.Length; j++)
            {
                if (str[j] == ' ')
                {
                    if (!doubleSpace)
                        wordCount++;

                    doubleSpace = true;
                    continue;
                }
                doubleSpace = false;
            }
            string[] st = new string[wordCount + 1];

            int i = 0;

            doubleSpace = false;
            string ch = "";
            for (int j = 0; j < str.Length; j++)
            {
                if (str[j] == ' ')
                {
                    if (!doubleSpace)
                    {
                        st[i] = sb.ToString();
                        sb.Delete(0, sb.Length());
                        i++;
                    }
                    doubleSpace = true;
                    continue;
                } else
                {
                    sb.Append(str[j]);
                }
                doubleSpace = false;
            }

            st[i] = sb.ToString();
            ;
            return st;
        }
开发者ID:Coopermine,项目名称:P25M_PRINTER,代码行数:57,代码来源:Util.cs


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