本文整理汇总了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");
}
}
示例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;
}
}
}
示例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();
}
示例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();
}
示例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());
}
}
示例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();
}
示例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();
}
示例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());
}
示例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());
}
示例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();
}
示例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);
}
示例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;
}
示例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();
}
示例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;
}
}
}
示例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();
}