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


C# StringBuilder.append方法代码示例

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


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

示例1: DoTest

 public void DoTest(StringBuilder failQueries)
 {
     bool pass = false;
     SrndQuery lq = null;
     try
     {
         lq = Parser.QueryParser.Parse(queryText);
         if (verbose)
         {
             Console.WriteLine("Query: " + queryText + "\nParsed as: " + lq.ToString());
         }
     }
     catch (ParseException e)
     {
         if (verbose)
         {
             Console.WriteLine("Parse exception for query:\n"
                               + queryText + "\n"
                               + e.Message);
         }
         pass = true;
     }
     if (!pass)
     {
         failQueries.append(queryText);
         failQueries.append("\nParsed as: ");
         failQueries.append(lq.toString());
         failQueries.append("\n");
     }
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:30,代码来源:ExceptionQueryTst.cs

示例2: escape

	/* XXX Called from Preprocessor [ugly]. */
	internal static void escape(StringBuilder buf, string cs) {
	    if (cs == null)
	    {
	        return;
	    }
		for (int i = 0; i < cs.length(); i++) {
			char	c = cs.charAt(i);
			switch (c) {
				case '\\':
					buf.append("\\\\");
					break;
				case '"':
					buf.append("\\\"");
					break;
				case '\n':
					buf.append("\\n");
					break;
				case '\r':
					buf.append("\\r");
					break;
				default:
					buf.append(c);
                    break;
			}
		}
	}
开发者ID:tanis2000,项目名称:CppNet,代码行数:27,代码来源:MacroTokenSource.cs

示例3: getMessage

 /**
  * Returns the message string of the DuplicateFormatFlagsException.
  *
  * @return the message string of the DuplicateFormatFlagsException.
  */
 public override String getMessage()
 {
     StringBuilder buffer = new StringBuilder();
     buffer.append("Flags of the DuplicateFormatFlagsException is'");
     buffer.append(flags);
     buffer.append("'");
     return buffer.toString();
 }
开发者ID:gadfly,项目名称:nofs,代码行数:13,代码来源:java.util.DuplicateFormatFlagsExceptions.cs

示例4: ToString

        public override String ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.append("[");
            sb.append(getAgentLocation());
            sb.append(", ");
            sb.append(getLocationState());
            sb.append("]");

            return sb.ToString();
        }
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:12,代码来源:VacuumEnvPercept.cs

示例5: concat

	private void concat(StringBuilder buf, Argument arg) {
		Iterator<Token>	it = arg.iterator();
		while (it.hasNext()) {
			Token	tok = it.next();
			buf.append(tok.getText());
		}
	}
开发者ID:tanis2000,项目名称:CppNet,代码行数:7,代码来源:MacroTokenSource.cs

示例6: toASCIILowerCase

 public static String toASCIILowerCase(String s)
 {
     int len = s.length();
     StringBuilder buffer = new StringBuilder(len);
     for (int i = 0; i < len; i++)
     {
         char c = s.charAt(i);
         if ('A' <= c && c <= 'Z')
         {
             buffer.append((char)(c + ('a' - 'A')));
         }
         else
         {
             buffer.append(c);
         }
     }
     return buffer.toString();
 }
开发者ID:gadfly,项目名称:nofs,代码行数:18,代码来源:org.apache.harmony.luni.util.Util.cs

示例7: quoteIllegal

        internal const String encoding = "utf-8"; //$NON-NLS-1$

        #endregion Fields

        #region Methods

        /**
         * All characters except letters ('a'..'z', 'A'..'Z') and numbers ('0'..'9')
         * and legal characters are converted into their hexidecimal value prepended
         * by '%'.
         * <p>
         * For example: '#' -> %23
         * Other characters, which are unicode chars that are not US-ASCII, and are
         * not ISO Control or are not ISO Space chars, are preserved.
         * <p>
         * Called from {@code URI.quoteComponent()} (for multiple argument
         * constructors)
         *
         * @param s
         *            java.lang.String the string to be converted
         * @param legal
         *            java.lang.String the characters allowed to be preserved in the
         *            string s
         * @return java.lang.String the converted string
         */
        internal static String quoteIllegal(String s, String legal)
        {
            //throws UnsupportedEncodingException {
            StringBuilder buf = new StringBuilder();
            for (int i = 0; i < s.length(); i++) {
                char ch = s.charAt(i);
                if ((ch >= 'a' && ch <= 'z')
                        || (ch >= 'A' && ch <= 'Z')
                        || (ch >= '0' && ch <= '9')
                        || legal.indexOf(ch) > -1
                        || (ch > 127 && !java.lang.Character.isSpaceChar(ch) && !java.lang.Character
                                .isISOControl(ch))) {
                    buf.append(ch);
                } else {
                    byte[] bytes = new String(new char[] { ch }).getBytes(encoding);
                    for (int j = 0; j < bytes.Length; j++) {
                        buf.append('%');
                        buf.append(digits.charAt((bytes[j] & 0xf0) >> 4));
                        buf.append(digits.charAt(bytes[j] & 0xf));
                    }
                }
            }
            return buf.toString();
        }
开发者ID:gadfly,项目名称:nofs,代码行数:49,代码来源:java.net.URIEncoderDecoder.cs

示例8: generateFileInput

 private KeyValuePair<List<List<string>>, string> generateFileInput(int count, string fieldDelimiter, bool hasWeights, bool hasPayloads)
 {
     List<List<string>> entries = new List<List<string>>();
     StringBuilder sb = new StringBuilder();
     bool hasPayload = hasPayloads;
     for (int i = 0; i < count; i++)
     {
         if (hasPayloads)
         {
             hasPayload = (i == 0) ? true : Random().nextBoolean();
         }
         KeyValuePair<List<string>, string> entrySet = GenerateFileEntry(fieldDelimiter, (!hasPayloads && hasWeights) ? Random().nextBoolean() : hasWeights, hasPayload);
         entries.Add(entrySet.Key);
         sb.append(entrySet.Value);
     }
     return new KeyValuePair<List<List<string>>, string>(entries, sb.toString());
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:17,代码来源:FileDictionaryTest.cs

示例9: GenerateFileEntry

 private KeyValuePair<List<string>, string> GenerateFileEntry(string fieldDelimiter, bool hasWeight, bool hasPayload)
 {
     List<string> entryValues = new List<string>();
     StringBuilder sb = new StringBuilder();
     string term = TestUtil.RandomSimpleString(Random(), 1, 300);
     sb.append(term);
     entryValues.Add(term);
     if (hasWeight)
     {
         sb.append(fieldDelimiter);
         long weight = TestUtil.NextLong(Random(), long.MinValue, long.MaxValue);
         sb.append(weight);
         entryValues.Add(weight.ToString());
     }
     if (hasPayload)
     {
         sb.append(fieldDelimiter);
         string payload = TestUtil.RandomSimpleString(Random(), 1, 300);
         sb.append(payload);
         entryValues.Add(payload);
     }
     sb.append("\n");
     return new KeyValuePair<List<string>, string>(entryValues, sb.toString());
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:24,代码来源:FileDictionaryTest.cs

示例10: toString

 public String toString() {
   StringBuilder buffer = new StringBuilder();
   buffer.append("mockFs{files:[");
   for(int i=0; i < files.size(); ++i) {
     if (i != 0) {
       buffer.append(", ");
     }
     buffer.append(files.get(i));
   }
   buffer.append("]}");
   return buffer.toString();
 }
开发者ID:CurtHagenlocher,项目名称:OrcSharp,代码行数:12,代码来源:TestInputOutputFormat.cs

示例11: toEscapedString

 /// <summary>
 /// Write this component value to result, escaping characters according to
 /// the NDN URI Scheme. This also adds "..." to a value with zero or more ".".
 /// This adds a type code prefix as needed, such as "sha256digest=".
 /// </summary>
 ///
 /// <param name="result">The StringBuffer to write to.</param>
 public void toEscapedString(StringBuilder result)
 {
     if (type_ == net.named_data.jndn.Name.Component.ComponentType.IMPLICIT_SHA256_DIGEST) {
         result.append("sha256digest=");
         net.named_data.jndn.util.Blob.toHex(value_.buf(), result);
     } else
         net.named_data.jndn.Name.toEscapedString(value_.buf(), result);
 }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:15,代码来源:Name.cs

示例12: parseNumber

	    /**
	     * Parses <code>source</code> for special double values.  These values
	     * include Double.NaN, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY.
	     *
	     * @param source the string to parse
	     * @param value the special value to parse.
	     * @param pos input/ouput parsing parameter.
	     * @return the special number.
	     */
	    private static Number parseNumber(String source, double value,
	                                      ParsePosition pos) {
	        Number ret = null;
	
	        StringBuilder sb = new StringBuilder();
	        sb.append('(');
	        sb.append(value);
	        sb.append(')');
	
	        int n = sb.length();
	        int startIndex = pos.getIndex();
	        int endIndex = startIndex + n;
	        if (endIndex < source.length()) {
	            if (source.substring(startIndex, endIndex).compareTo(sb.toString()) == 0) {
	                ret = Double.valueOf(value);
	                pos.setIndex(endIndex);
	            }
	        }
	
	        return ret;
	    }
开发者ID:HankG,项目名称:Apache.Commons.Math,代码行数:30,代码来源:CompositeFormat.cs

示例13: convertPattern

 protected internal virtual String convertPattern(String template, String fromChars, String toChars,
         bool check)
 {
     if (!check && fromChars.equals(toChars)) {
         return template;
     }
     bool quote = false;
     StringBuilder output = new StringBuilder();
     int length = template.length();
     for (int i = 0; i < length; i++) {
         int index;
         char next = template.charAt(i);
         if (next == '\'') {
             quote = !quote;
         }
         if (!quote && (index = fromChars.indexOf(next)) != -1) {
             output.append(toChars.charAt(index));
         } else if (check
                 && !quote
                 && ((next >= 'a' && next <= 'z') || (next >= 'A' && next <= 'Z'))) {
             // text.05=Invalid pattern char {0} in {1}
             throw new java.lang.IllegalArgumentException("Invalid pattern char "+next+" in "+ template); //$NON-NLS-1$
         } else {
             output.append(next);
         }
     }
     if (quote) {
         // text.04=Unterminated quote
         throw new java.lang.IllegalArgumentException("Unterminated quote"); //$NON-NLS-1$
     }
     return output.toString();
 }
开发者ID:sailesh341,项目名称:JavApi,代码行数:32,代码来源:Format.cs

示例14: readLine

 public String readLine()
 {
     //throws IOException {
     StringBuilder line = new StringBuilder(80); // Typical line length
     bool foundTerminator = false;
     while (true) {
         int nextByte = inJ.read();
         switch (nextByte) {
             case -1:
                 if (line.Length == 0 && !foundTerminator) {
                     return null;
                 }
                 return line.toString();
             case (byte) '\r':
                 if (foundTerminator) {
                     ((PushbackInputStream) inJ).unread(nextByte);
                     return line.toString();
                 }
                 foundTerminator = true;
                 /* Have to be able to peek ahead one byte */
                 if (!(inJ is PushbackInputStream)) { //think Bug in Harmony, not test on class but on type required
                     inJ = new PushbackInputStream(inJ);
                 }
                 break;
             case (byte) '\n':
                 return line.toString();
             default:
                 if (foundTerminator) {
                     ((PushbackInputStream) inJ).unread(nextByte);
                     return line.toString();
                 }
                 line.append((char) nextByte);
                 break;
         }
     }
 }
开发者ID:sailesh341,项目名称:JavApi,代码行数:36,代码来源:DataInputStream.cs

示例15: toUri

        /// <summary>
        /// Encode this Exclude with elements separated by "," and Exclude.Type.ANY
        /// shown as "///".
        /// </summary>
        ///
        /// <returns>the URI string</returns>
        public String toUri()
        {
            if ((entries_.Count==0))
                return "";

            StringBuilder result = new StringBuilder();
            for (int i = 0; i < entries_.Count; ++i) {
                if (i > 0)
                    result.append(",");

                if (get(i).getType() == net.named_data.jndn.Exclude.Type.ANY)
                    result.append("*");
                else
                    get(i).getComponent().toEscapedString(result);
            }

            return result.toString();
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:24,代码来源:Exclude.cs


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