Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Home » Tip Bank » .NET » C#
Language: .NET
Expertise: Beginner
Apr 20, 2018

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Format the Console.Write Responses

We use string.format to format the data written to the console using the console.write or console.writeline commands. However, it isn't indented well to make it readable. C# allows you to bridge this gap by supporting the addition of spaces and thus providing the formatted and indented output.

for (int counter=0 ; counter  {
Console.WriteLine(string.Format("Collection Key: {0,-5} Value: {1,5}"), collection[counter].key, collection[counter].value);
}

As you already know, the numbers 0 and 1 are used to position the value of the variables in the formatted response string. The numbers -5 and 5 allow you to left align and right align the text within 5 spaces.

Srinath M S
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date