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


C# StringBuffer.Append方法代码示例

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


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

示例1: buf2String

        /**
         * convert byte array to Hex String.
         *
         * @param info - the propmt String
         * @param buf - the byte array which will be converted
         * @param offset - the start position of buf
         * @param length - the converted length
         * @param isOneLine16 - if true 16 bytes one line, false all bytes in one line
         * @return Hex String
         */
        public static string buf2String(string info, byte[] buf, int offset,
			int length, bool oneLine16)
        {
            int i, index;

            StringBuffer sBuf = new StringBuffer();
            sBuf.Append(info);

            for (i = 0 + offset; i < length + offset; i++)
            {
                if (i % 16 == 0)
                {
                    if (oneLine16)
                    {
                        sBuf.Append(lineSeperate);
                    }
                } else if (i % 8 == 0)
                {
                    if (oneLine16)
                    {
                        sBuf.Append("   ");
                    }
                }
                index = buf[i] < 0 ? buf[i] + DEFAULT_TABLE_LENGTH : buf[i];
                sBuf.Append(convertTable[index]);
            }
            return sBuf.ToString();
        }
开发者ID:Coopermine,项目名称:P25M_PRINTER,代码行数:38,代码来源:ByteConverter.cs

示例2: IsExtendedTest

    public void IsExtendedTest(string path, bool expected)
    {
        StringBuffer sb = new StringBuffer();
        sb.Append(path);
        Assert.Equal(expected, PathInternal.IsExtended(sb));

        Assert.Equal(expected, PathInternal.IsExtended(path));
    }
开发者ID:shmao,项目名称:corefx,代码行数:8,代码来源:PathInternal.Windows.Tests.cs

示例3: ByteArrayToHexString

        private static string ByteArrayToHexString(byte[] b)
        {
            StringBuffer resultSb = new StringBuffer();
            for (int i = 0; i < b.Length; i++)
                resultSb.Append(ByteToHexString(b[i]));

            return resultSb.ToString();
        }
开发者ID:MicahelWang,项目名称:XamarinSamples,代码行数:8,代码来源:MD5Util.cs

示例4: Test1

		public void Test1()
		{
			StringBuffer buf = new StringBuffer(100);
			
			Assert.AreEqual(0, buf.Length);
			Assert.AreEqual("", buf.ToString());
			
			buf.Append('a');
			buf.Append('b');
			buf.Append('c');
			
			Assert.AreEqual(3, buf.Length);
			Assert.AreEqual("abc", buf.ToString());
			
			buf.Clear();
			
			Assert.AreEqual(0, buf.Length);
			Assert.AreEqual("", buf.ToString());
		}
开发者ID:kaijin-games,项目名称:larning-english-game,代码行数:19,代码来源:HtmlParserTest.cs

示例5: FormatDouble

        public static void FormatDouble(StringBuffer formatter, double value, StringView specifier, CachedCulture culture)
        {
            int digits;
            int precision = DoublePrecision;
            var fmt = ParseFormatSpecifier(specifier, out digits);

            // ANDing with 0xFFDF has the effect of uppercasing the character
            switch (fmt & 0xFFDF) {
                case 'G':
                    if (digits > 15)
                        precision = 17;
                    break;

                case 'E':
                    if (digits > 14)
                        precision = 17;
                    break;
            }

            var number = new Number();
            var buffer = stackalloc char[MaxFloatingDigits + 1];
            number.Digits = buffer;
            DoubleToNumber(value, precision, ref number);

            if (number.Scale == ScaleNaN) {
                formatter.Append(culture.NaN);
                return;
            }

            if (number.Scale == ScaleInf) {
                if (number.Sign > 0)
                    formatter.Append(culture.NegativeInfinity);
                else
                    formatter.Append(culture.PositiveInfinity);
                return;
            }

            if (fmt != 0)
                NumberToString(formatter, ref number, fmt, digits, culture);
            else
                NumberToCustomFormatString(formatter, ref number, specifier, culture);
        }
开发者ID:aka-STInG,项目名称:StringFormatter,代码行数:42,代码来源:Numeric.cs

示例6: GetColourString

        string GetColourString()
        {
            int count = 0;
            for( int i = ' '; i <= '~'; i++ ) {
                if( i >= 'A' && i <= 'F' ) continue;
                if( game.Drawer2D.Colours[i].A > 0 ) count++;
            }

            StringBuffer buffer = new StringBuffer( count * 4 );
            int index = 0;
            for( int i = ' '; i <= '~'; i++ ) {
                if( i >= 'A' && i <= 'F' ) continue;
                if( game.Drawer2D.Colours[i].A == 0 ) continue;

                buffer.Append( ref index, '&' ).Append( ref index, (char)i )
                    .Append( ref index, '%' ).Append( ref index, (char)i );
            }
            return buffer.ToString();
        }
开发者ID:Chameleonherman,项目名称:ClassicalSharp,代码行数:19,代码来源:AltTextInputWidget.Types.cs

示例7: ToStringBuffer

        /// <summary>
        /// Returns a human readable text of this entry
        /// </summary>
        /// <returns></returns>
        public unsafe StringBuffer ToStringBuffer()
        {
            var buf = new StringBuffer();

            buf.Append("0x");
            buf.Append((uint)MethodDefinition->Method, "X");
            buf.Append("+0x");
            buf.Append(Offset, "X");
            buf.Append(" ");

            var idx = MethodName.IndexOf(' ') + 1; //Skip return type
            buf.Append(MethodName, idx);
            return buf;
        }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:18,代码来源:SimpleStackTraceEntry.cs

示例8: ReadAllText

 /// <summary>
 /// Read a file with given path and return a string with it's entire contents.
 /// </summary>
 public static string ReadAllText(string path)
 {
     if (path == null)
         throw new ArgumentNullException("path");
     var file = new JFile(path);
     if (!file.Exists() || !file.IsFile())
         throw new FileNotFoundException(path);
     if (!file.CanRead())
         throw new UnauthorizedAccessException(path);
     var reader = new FileReader(file);
     try
     {
         var array = new char[4096];
         var buffer = new StringBuffer();
         int len;
         while ((len = reader.Read(array, 0, array.Length)) > 0)
         {
             buffer.Append(array, 0, len);
         }
         return buffer.ToString();
     }
     finally
     {
         reader.Close();
     }
 }
开发者ID:nguyenkien,项目名称:api,代码行数:29,代码来源:File.cs

示例9: 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

示例10: AppendHex

 private static void AppendHex(StringBuffer stringbuffer, byte byte0)
 {
     stringbuffer.Append (toHexChar (byte0 >> 4));
     stringbuffer.Append (toHexChar (byte0));
 }
开发者ID:Coopermine,项目名称:P25M_PRINTER,代码行数:5,代码来源:StringUtil.cs

示例11: ReadToEnd

 /// <summary>
 /// Read the remainder of the reader and return it as string.
 /// </summary>
 public virtual string ReadToEnd()
 {
     var tmp = new char[4096];
     var buffer = new StringBuffer();
     int len;
     while ((len = Read(tmp, 0, tmp.Length)) > 0)
     {
         buffer.Append(tmp, 0, len);
     }
     return buffer.ToString();
 }
开发者ID:sebastianhaba,项目名称:api,代码行数:14,代码来源:TextReader.cs

示例12: 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

示例13: Int64ToHexStr

        static void Int64ToHexStr(StringBuffer formatter, ulong value, int hexBase, int digits)
        {
            var buffer = stackalloc char[100];
            char* ptr;
            if (High32(value) != 0) {
                Int32ToHexChars(buffer + 100, Low32(value), hexBase, 8);
                ptr = Int32ToHexChars(buffer + 100 - 8, High32(value), hexBase, digits - 8);
            }
            else {
                if (digits < 1)
                    digits = 1;
                ptr = Int32ToHexChars(buffer + 100, Low32(value), hexBase, digits);
            }

            formatter.Append(ptr, (int)(buffer + 100 - ptr));
        }
开发者ID:aka-STInG,项目名称:StringFormatter,代码行数:16,代码来源:Numeric.cs

示例14: loadConvert

        /*
           * Converts encoded &#92;uxxxx to unicode chars and changes special saved
           * chars to their original forms
           *
           * @param s
           *            the  byte arrary needing convert.
           * @param offset
           *            the offset of byte arrary
           * @param lengthFlag
           *            Whether add one byte of length in the result.
           *            <code>true</code> add one byte of length in the result
           * @return  the convert result of the byte arrary.
           */
        public static string loadConvert(byte[] s, int offset, bool lengthFlag)
        {
            if (null == s || (offset + (lengthFlag ? 1 : 0)) > s.Length)
                throw new IllegalArgumentException ("invalid byte arrary");

            char aChar;
            int len = (s.Length - offset);

            if (lengthFlag) {
                len = s [offset] & 0xFF;
                offset++;
            }

            StringBuffer outBuffer = new StringBuffer (len);

            for (int x = offset; x < (offset + len);) {
                aChar = (char)s [x++];
                if (aChar == '\\') {
                    aChar = (char)s [x++];
                    if (aChar == 'u') {
                        // Read the xxxx
                        int value = 0;
                        for (int i = 0; i < 4; i++) {
                            aChar = (char)s [x++];
                            switch (aChar) {
                            case '0':
                            case '1':
                            case '2':
                            case '3':
                            case '4':
                            case '5':
                            case '6':
                            case '7':
                            case '8':
                            case '9':
                                value = (value << 4) + aChar - '0';
                                break;
                            case 'a':
                            case 'b':
                            case 'c':
                            case 'd':
                            case 'e':
                            case 'f':
                                value = (value << 4) + 10 + aChar - 'a';
                                break;
                            case 'A':
                            case 'B':
                            case 'C':
                            case 'D':
                            case 'E':
                            case 'F':
                                value = (value << 4) + 10 + aChar - 'A';
                                break;
                            default:
                                throw new IllegalArgumentException ("Malformed \\uxxxx encoding.");
                            }
                        }
                        outBuffer.Append ((char)value);
                    } else {
                        if (aChar == 't')
                            aChar = '\t';
                        else if (aChar == 'r')
                            aChar = '\r';
                        else if (aChar == 'n')
                            aChar = '\n';
                        else if (aChar == 'f')
                            aChar = '\f';
                        outBuffer.Append (aChar);
                    }
                } else
                    outBuffer.Append (aChar);
            }
            return outBuffer.ToString ();
        }
开发者ID:Coopermine,项目名称:P25M_PRINTER,代码行数:87,代码来源:StringUtil.cs

示例15: fillstring

        /**
          * Method fill string
          *
          * @param The string to be format.
          *
          */
        public static string fillstring(string formatString, int length, char fillChar, bool leftFillFlag)
        {
            if (null == formatString) {
                formatString = "";
            }
            int strLen = formatString.Length;
            if (strLen >= length) {
                if (true == leftFillFlag)  // left fill
                    return formatString.Substring (strLen - length, strLen);
                else
                    return formatString.Substring (0, length);
            } else {
                StringBuffer sbuf = new StringBuffer ();
                int fillLen = length - formatString.Length;
                for (int i = 0; i < fillLen; i++) {
                    sbuf.Append (fillChar);
                }

                if (true == leftFillFlag) {  // left fill
                    sbuf.Append (formatString);
                } else {
                    sbuf.Insert (0, formatString);
                }
                string returnstring = sbuf.ToString ();
                sbuf = null;
                return returnstring;
            }
        }
开发者ID:Coopermine,项目名称:P25M_PRINTER,代码行数:34,代码来源:StringUtil.cs


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