本文整理汇总了C#中this.AppendLine方法的典型用法代码示例。如果您正苦于以下问题:C# this.AppendLine方法的具体用法?C# this.AppendLine怎么用?C# this.AppendLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类this
的用法示例。
在下文中一共展示了this.AppendLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AppendSuggestImmutable
internal static StringBuilder AppendSuggestImmutable(this StringBuilder errorBuilder, TypeErrors errors)
{
var fixableTypes = errors.AllErrors.OfType<TypeErrors>()
.Where(x => x.Type != errors.Type)
.Select(x => x.Type)
.Distinct()
.ToArray();
if (!fixableTypes.Any())
{
return errorBuilder;
}
foreach (var type in fixableTypes)
{
var line = type.Assembly == typeof(int).Assembly
? $"* Use an immutable type instead of {type.PrettyName()}."
: $"* Make {type.PrettyName()} immutable or use an immutable type.";
errorBuilder.AppendLine(line);
}
errorBuilder.AppendLine(" - For immutable types the following must hold:")
.AppendLine(" - Must be a sealed class or a struct.")
.AppendLine(" - All fields and properties must be readonly.")
.AppendLine(" - All field and property types must be immutable.")
.AppendLine(" - All indexers must be readonly.")
.AppendLine(" - Event fields are ignored.");
return errorBuilder;
}
示例2: AppendLine
/// <summary>
/// Appends the .ToString() value of the object supplied along with the default line terminator.
/// </summary>
public static StringBuilder AppendLine(this StringBuilder that, object value) {
if (value == null) {
return that.AppendLine();
}
else {
return that.AppendLine(value.ToString());
}
}
示例3: AppendTriggerable
private static void AppendTriggerable(this StringBuilder builder, Triggerable triggerable)
{
builder.AppendLine(" [TRIGGERABLE]");
builder.AppendFormat(" <STRING>Name:{0}\r\n", triggerable.Name);
builder.AppendFormat(" <STRING>File:{0}\r\n", triggerable.File);
builder.AppendLine(" [/TRIGGERABLE]");
}
示例4: IndentedLines
public static void IndentedLines(this StringBuilder sb, String text)
{
string indent = new string(' ', tabs * 4);
if (text.Contains("@\"")) //no splitting for verbatim strings
sb.AppendLine(indent + text);
else
foreach (var line in text.Split('\n'))
sb.AppendLine(indent + line.TrimEnd());
}
示例5: AppendWatcherChangesetPart
private static StringBuilder AppendWatcherChangesetPart(this StringBuilder sb, Dictionary<string, string> changesetPart, string name) {
if (changesetPart.Count > 0) {
sb.AppendLine(name);
foreach (var item in changesetPart) {
sb.AppendLine($"{item.Key} -> {item.Value}");
}
}
return sb;
}
示例6: AppendConsoleFormat
public static string AppendConsoleFormat(this StringBuilder builder)
{
builder.AppendLine("Retrieving the amount of customers and orders per city in the USA:");
builder.Append(Environment.NewLine);
builder.AppendLine(string.Format("{0,-54} {1,11} {2,11}", "-".Repeat(54), "-".Repeat(11), "-".Repeat(11)));
builder.AppendLine(string.Format("{0,-54} {1,11} {2,11}", "City", "Customers", "Orders"));
builder.AppendLine(string.Format("{0,-54} {1,11} {2,11}", "-".Repeat(54), "-".Repeat(11), "-".Repeat(11)));
return builder.ToString();
}
示例7: AppendConsoleFormat
public static string AppendConsoleFormat(this StringBuilder builder)
{
builder.AppendLine("1. Created by loading the XML file, displaying first 3 elements:");
builder.Append(Environment.NewLine);
builder.AppendLine(string.Format("{0,-25} {1,-25} {2,-15} {3,10}", "-".Repeat(25), "-".Repeat(25), "-".Repeat(15), "-".Repeat(10)));
builder.AppendLine(string.Format("{0,-25} {1,-25} {2,-15} {3,-10}", "Title", "Author", "Published", "Price"));
builder.AppendLine(string.Format("{0,-25} {1,-25} {2,-15} {3,10}", "-".Repeat(25), "-".Repeat(25), "-".Repeat(15), "-".Repeat(10)));
return builder.ToString();
}
示例8: AppendLineFormat
/// <summary>
/// Appends a NewLine after the format string. Safe formatting for null/empty pArgs.
/// </summary>
/// <returns></returns>
public static void AppendLineFormat(this StringBuilder pSb, string pFormat, params object[] pArgs)
{
if (pArgs != null && pArgs.Any())
{
pSb.AppendFormat(pFormat, pArgs);
pSb.AppendLine();
}
else
pSb.AppendLine(pFormat);
}
示例9: AppendSkill
private static void AppendSkill(this StringBuilder builder, Skill skill)
{
builder.AppendLine(" [SKILL]");
builder.AppendFormat(" <INTEGER64>GUID:{0}\r\n", skill.GUID);
builder.AppendFormat(" <STRING>Name:{0}\r\n", skill.Name);
builder.AppendFormat(" <STRING>File:{0}\r\n", skill.File);
builder.AppendLine(" [/SKILL]");
}
示例10: AppendIfNotEmpty
public static bool AppendIfNotEmpty( this StringBuilder sb, string line, int index, string pre = "" )
{
if( !string.IsNullOrEmpty( line ) )
{
if( !string.IsNullOrEmpty( pre ) )
sb.AppendLine( pre );
sb.AppendLine( "\t" + index + ": " + line );
return true;
}
return false;
}
示例11: IndentAppendLines
public static void IndentAppendLines(this StringBuilder b, int pad, string text)
{
foreach (var line in text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None))
{
if (string.IsNullOrWhiteSpace(line))
b.AppendLine();
else
{
b.Append(' ', pad); b.AppendLine(line);
}
}
}
示例12: AppendLine
/// <summary>
/// Appends the format line.
/// </summary>
/// <param name="sb">The sb.</param>
/// <param name="str">The STR.</param>
/// <param name="args">The args.</param>
public static void AppendLine(this StringBuilder sb, string str, params object[] args)
{
if (args == null || args.Length == 0)
{
sb.AppendLine(str);
}
else
{
sb.AppendFormat(str, args);
sb.AppendLine();
}
}
示例13: WriteHelpPage
private static void WriteHelpPage(this StringBuilder sb, HelpPage page, int maxWidth)
{
sb.WriteUsage(page.ApplicationName, page.SyntaxElements, maxWidth);
if (!page.Rows.Any())
return;
sb.AppendLine();
sb.WriteRows(page.Rows, maxWidth);
sb.AppendLine();
}
示例14: AppendUserInterface
private static void AppendUserInterface(this StringBuilder builder, UserInterface userInterface)
{
builder.AppendLine(" [USERINTERFACE]");
builder.AppendFormat(" <STRING>Name:{0}\r\n", userInterface.Name);
builder.AppendFormat(" <STRING>File:{0}\r\n", userInterface.File);
builder.AppendFormat(" <INTEGER>Unknown:{0}\r\n", userInterface.Unknown);
builder.AppendFormat(" <INTEGER>Unknown2:{0}\r\n", userInterface.Unknown2);
builder.AppendFormat(" <SHORT>Unknown3:{0}\r\n", userInterface.Unknown3);
builder.AppendFormat(" <BOOL>Unknown4:{0:X2}\r\n", userInterface.Unknown4.Value ? "True" : "False");
builder.AppendFormat(" <STRING>Unknown5:{0}\r\n", userInterface.Unknown5);
builder.AppendLine(" [/USERINTERFACE]");
}
示例15: AppendLineFormat
public static StringBuilder AppendLineFormat(this StringBuilder sb, string value, params object[] parameters)
{
if ((parameters == null) || (parameters.Length == 0))
return sb.AppendLine(value);
List<object> newparams = new List<object>();
foreach (var p in parameters)
if (p == null)
newparams.Add(string.Empty);
else
newparams.Add(p);
sb.AppendFormat(value, newparams.ToArray());
return sb.AppendLine();
}