本文整理汇总了C#中System.Text.StringBuilder.RemoveLastCharacter方法的典型用法代码示例。如果您正苦于以下问题:C# StringBuilder.RemoveLastCharacter方法的具体用法?C# StringBuilder.RemoveLastCharacter怎么用?C# StringBuilder.RemoveLastCharacter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Text.StringBuilder
的用法示例。
在下文中一共展示了StringBuilder.RemoveLastCharacter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToPostBuffer
public static byte[] ToPostBuffer(this IEnumerable<KeyValuePair<string, string>> list)
{
var queryString = new StringBuilder();
foreach (var keyValuePair in list)
{
queryString.Append(string.Format("{0}={1}&", keyValuePair.Key, keyValuePair.Value));
}
queryString.RemoveLastCharacter();
return Encoding.ASCII.GetBytes(queryString.ToString());
}
示例2: ToQueryString
public static string ToQueryString(this IEnumerable<KeyValuePair<string, string>> list)
{
var queryString = new StringBuilder();
foreach (var keyValuePair in list)
{
queryString.Append(string.Format("{0}={1}&", keyValuePair.Key, keyValuePair.Value));
}
queryString.RemoveLastCharacter();
return queryString.ToString();
}
示例3: SEONormalize
public static string SEONormalize(this string title, int maxLength = 60)
{
if (string.IsNullOrWhiteSpace(title))
return string.Empty;
title = title.Trim();
int len = title.Length;
bool prevdash = false;
var sb = new StringBuilder(len);
for (int i = 0; i < len && i < maxLength; i++)
{
char c = title[i];
if (c.IsAlphaNumeric())
{
sb.Append(c.ToLower());
prevdash = false;
}
else if (c.In('´', '’'))
{
sb.Append('\'');
prevdash = false;
}
else if (c.In(' ', ',', '.', '/', '\\', '-', '_', '='))
{
if (!prevdash && sb.Length > 0)
{
sb.Append('-');
prevdash = true;
}
}
else if ((int)c >= 128)
{
var fc = c.FoldDiacritical().ToLower();
if (fc.IsValidUriPathSegment())
{
sb.Append(fc);
prevdash = false;
}
}
}
if (prevdash)
sb.RemoveLastCharacter();
return sb.ToString();
}