.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Code Snippets >> Validations >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Write formatted output

Posted By:shiv chandra       Posted Date: June 29, 2011    Points: 40    Category: Validations    URL: http://www.dotnetspark.com  

Write formatted output

int sample = 16;
Console.WriteLine(" '{0,-8}'", sample);     // output :  '16      '
Console.WriteLine(" '{0,8}'", sample);      // output :   '      16'
Console.WriteLine(" '{0,8}'","Shiv"); // output :  '    Shiv'
Console.WriteLine(" '{0,-8}'","Shiv");// output : 'Shiv    '
Console.WriteLine(" '{0:X}'",sample);      //(in HEX) output : '10'
Console.WriteLine(" '{0:X10}'", sample);    //(in HEX) output :'0000000010'
Console.WriteLine( 1234567.ToString("#,##0")); // writes with commas: 1,234,567


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend