@Rajoli Hari Krishna , based on my test, I reproduced your problem.
First, We need to set the column before we want to use ConsoleTable.
var table = new ConsoleTable("Day No", "Daily Saving", "Total Saved");
Second, Please add rows in the loop.
for (int i = 1; i <= daysInYear; i++)
{
table.AddRow(i, (i * 2), (i * (i + 1)));
}
Finally, you could use the following code to show the table in the console:
table.Write();
Completed code example:
DateTime currentDate = DateTime.Now;
int daysInYear = DateTime.IsLeapYear(currentDate.Year) ? 366 : 365;
int daysLeftInYear = daysInYear - currentDate.DayOfYear; // Result is in range 0-365.
int finisheddaysCount = daysInYear - daysLeftInYear;
Console.WriteLine("daysLeftInYear is {0}", daysLeftInYear);
Console.WriteLine("finishedDaysCount is {0}", finisheddaysCount);
int savings = (daysInYear * (daysInYear + 1)) - (finisheddaysCount * (finisheddaysCount - 1));
Console.WriteLine(savings);
//Case 2:
Console.WriteLine("_________________________________");
var table = new ConsoleTable("Day No", "Daily Saving", "Total Saved");
for (int i = 1; i <= daysInYear; i++)
{
table.AddRow(i, (i * 2), (i * (i + 1)));
}
table.Write();
Console.ReadKey();
Result:
Hope this could help you.
Best Regards,
Jack
If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.