int intLines;
string str;
TextReader txtReader;
txtReader = Console.In;
Console.WriteLine("How many lines need to be displayed?");
intLines = Convert.ToInt16(txtReader.ReadLine());
Console.WriteLine("Enter the character to be placed as triangle?");
str = txtReader.ReadLine();
Console.Clear();
StringBuilder strBuilder = new StringBuilder(str);
int intCursorYposition = 0;
int intCursorXposition = Console.BufferWidth / 2;
for (int i = 0; i < intLines; i++)
{
if (i % 2 != 0)
{
intLines++;
strBuilder.Append(str);
continue;
}
try
{
Console.SetCursorPosition(intCursorXposition, intCursorYposition);
}
catch (Exception)
{
Console.BackgroundColor = System.ConsoleColor.Blue;
Console.WriteLine("You have entered too large line value that console could not display\nProgram closing");
Console.Beep();
throw new Exception("Exit");
}
Console.Write(strBuilder);
strBuilder.Append(str);
Console.WriteLine();
intCursorYposition++;
intCursorXposition--;
In any new application handling TimeZone/DateTime is mostly least priority and generally, if someone is concerned then it would be handled by using DateTime.UtcNow on codes while creating current dates and converting incoming Date to UTC to save on servers. Basically, the process is followed by saving DateTime to UTC format in a database and keep converting data to native format based on user region or single region in the application's presentation layer. The above is tedious work and have to be followed religiously. If any developer misses out the manual conversion, then that area of code/view would not work. With newer frameworks, there are flexible ways to deal/intercept incoming or outgoing calls to simplify conversion of TimeZones. These are steps/process to achieve it. 1. Central code for storing user's state about TimeZone. Also, central code for conversion logic based on TimeZones. 2. Dependency injection for the above class to be able to use global
Comments
Post a Comment