String right left alignment with spaces using C#.Net
In this example i am explaining how to align string with right and left alignment using C#.Net. This is one of the c#.net Interview Questions
Example Code:
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace StringFormats { class Program { static void Main(string[] args) { Console.WriteLine("**********************************************"); Console.WriteLine("F name |L Name |Salary"); Console.WriteLine("**********************************************"); Console.WriteLine(String.Format("{0,-15} | {1,-18} | {2,6}", "Ranga", "Rajesh", 50000)); Console.WriteLine(String.Format("{0,-15} | {1,-18} | {2,6}", "Swapna", "Rajesh",60000)); Console.WriteLine("-------------------------------"); Console.ReadLine(); } } }
Output:
String right left alignment with spaces using C#.Net |
Post a Comment
Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.