You can do something like this:
Console.WriteLine(String.Format("{0,-10} | {1,5}", "Bill", 51));
You’ll get “51” aligned to right on 5 characters.
More examples here: Align String with Spaces.
For official reference, see Composite Formatting
More Related Contents:
- .NET String.Format() to add commas in thousands place for a number
- Parse C# string to DateTime
- Formatting a string into columns using String Interpolation
- Escape double quotes in a string
- Can I convert a C# string value to an escaped string literal?
- Get string between two strings in a string
- String output: format or concat in C#?
- Differences in string compare methods in C#
- Efficient way to remove ALL whitespace from String?
- Comparing two strings, ignoring case in C# [duplicate]
- How to replace multiple white spaces with one white space
- Convert JSON String to JSON Object c#
- Is there an alternative to string.Replace that is case-insensitive?
- Can I “multiply” a string (in C#)?
- Java equivalents of C# String.Format() and String.Join()
- Need to perform Wildcard (*,?, etc) search on a string using Regex
- Is String a primitive type?
- How to split a number into individual digits in c#? [duplicate]
- If strings are immutable in .NET, then why does Substring take O(n) time?
- Convert XmlDocument to String
- How do I get the last four characters from a string in C#?
- Do string literals get optimised by the compiler?
- How do I format a Decimal to a programatically controlled number of decimals in c#?
- Regex nested parentheses
- How many String objects will be created when using a plus sign?
- How to remove empty lines from a formatted string
- Convert String^ in c# to CString in c++/CLI
- Adding a newline into a string in C#
- Using StreamReader to check if a file contains a string
- How can I create all possible combinations for a set of words without repetition?