Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi,
Please give code in c#.net to display string as shown below

TestId    ApiName    ActualOutPut     ExpectedOutPut
1         abc        asdfsa           sdfsdf
2         dfhgfh     fvhfdfhfh        fxgfxgfg
Posted
Updated 1-Aug-11 21:09pm
v2
Comments
Sergey Alexandrovich Kryukov 2-Aug-11 1:12am    
Why?
Also, the question is not clear; UI library is not tagged: WPF, WinForms, ASP.NET, Console, what?!
--SA
LittleYellowBird 2-Aug-11 3:17am    
Hi, I suggest that yoiu have a go at this yourself and if the code doesn't work post it here and perhaps someone will be able to help. :) Ali

1 solution

There are a number of ways to do it, which is best for you is going to depend on how you are displaying the info, and where you are sourcing it.

If you are sourcing the data from a database, then the easiest way is to read the information into a DataTable, and use that as the DataSource Property of a DateGrid or DataGridView.
If you need it displayed on the console, then just using the format length specifiers may be enough:
C#
string TestId = "1";
string ApiName = "abc";
string ActualOutPut = "asdfsa";
string ExpectedOutPut = "sdfsdf";
Console.WriteLine("{0,8} {1,8} {2,8} {3,8}", TestId, ApiName, ActualOutPut, ExpectedOutPut);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900