hello, im trying to display a header in my output and have looked at a code from an example in my book but added a few more variables to it. The book only has two but I have five and after I changed the example to include all my five it only shows the first two.

here is the part of my code

// display headers
         Console.WriteLine("Year{0, 20}", "Rate",  "Amount", "Interest", "New Amount");

this is the output it shows
Year Rate

but i want it to show

Year Rate Amount Interest New Amount

The {0,20} is a placeholder and format specifier for a variable that was in the other example you had. For example:

int i = 1;
char a = 'a';
double pi = 3.14159;
Console.WriteLine("{0} {1} {2}",i,a,pi);

prints out: 1 a 3.14145 (each placeholder is replaced by the value)

So for your application, you can just simply make it one string: Console.WriteLine("Year Rate Amount Interest New Amount"); or if you want the year in there Console.WriteLine("Year {0} Rate Amount Interest New Amount",year);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.