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--;
This is a very simple trick to handle JSON date format on AspNet Core by global settings. This can be applicable for the older version as well. In a newer version by default, .Net depends upon Newtonsoft to process any JSON data. Newtonsoft depends upon Newtonsoft.Json.Converters.IsoDateTimeConverter class for processing date which in turns adds timezone for JSON data format. There is a global setting available for same that can be adjusted according to requirement. So, for example, we want to set default formatting to US format, we just need this code. services.AddMvc() .AddJsonOptions(options => { options.SerializerSettings.DateTimeZoneHandling = "MM/dd/yyyy HH:mm:ss"; });
Comments
Post a Comment