Articles on Trending Technologies

Technical articles with clear explanations and examples

How to change the WindowLeft of the Console

AmitDiwan
AmitDiwan
Updated on 14-Nov-2019 169 Views

Use the Console.WindowLeft Property to change the WindowLeft of the Console in C#.ExampleLet us now see an example −using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Demo {    public static void Main (string[] args) {       Console.InputEncoding = Encoding.ASCII;       Console.WriteLine("Input Encoding Scheme = "+Console.InputEncoding);       Console.OutputEncoding = Encoding.ASCII;       Console.WriteLine("Output Encoding Scheme = "+Console.OutputEncoding);       Console.CursorVisible = false;       Console.Write("Cursor is Visible? "+ Console.CursorVisible);       Console.WindowLeft = 50;       Console.Write("WindowLeft = "+Console.WindowLeft);    } } OutputThis will produce ...

Read More

How to change the visibility of the Cursor of Console in C#

AmitDiwan
AmitDiwan
Updated on 14-Nov-2019 473 Views

To change the visibility of the Cursor, use the Console.CursorVisible property.ExampleLet us see an example −using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Demo {    public static void Main (string[] args) {       Console.BackgroundColor = ConsoleColor. Black;       Console.WriteLine("Background color changed = "+Console.BackgroundColor);       Console.ForegroundColor = ConsoleColor.White;       Console.WriteLine("Foreground color changed = "+Console.ForegroundColor);       Console.InputEncoding = Encoding.ASCII;       Console.WriteLine("Input Encoding Scheme = "+Console.InputEncoding);       Console.OutputEncoding = Encoding.ASCII;       Console.WriteLine("Output Encoding Scheme = "+Console.OutputEncoding);       Console.CursorVisible = false;   ...

Read More

MathF.Floor() Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 14-Nov-2019 178 Views

The MathF.Floor() method in C# is used to find the largest integer, which is less than or equal to the specified float value.SyntaxFollowing is the syntax −public static float Floor (float val);Above, the Val is the floating-point value.ExampleLet us now see an example to implement the MathF.Floor() method −using System; class Demo {    public static void Main(){       float val = 45.67f;       float res = MathF.Floor(val);       Console.WriteLine("MathF.Floor() = "+res);    } }OutputThis will produce the following output −MathF.Floor() = 45ExampleLet us now see another example to implement the MathF.Floor() method −using ...

Read More

How to change the Output Encoding Scheme of the C# Console?

AmitDiwan
AmitDiwan
Updated on 14-Nov-2019 407 Views

Use the Console.OutputEncoding property in C# to change the Output Encoding Scheme in C#.ExampleLet us see an example −using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Demo {    public static void Main (string[] args) {       Console.BackgroundColor = ConsoleColor. Black;       Console.WriteLine("Background color changed = "+Console.BackgroundColor);       Console.ForegroundColor = ConsoleColor.White;       Console.WriteLine("Foreground color changed = "+Console.ForegroundColor);       Console.InputEncoding = Encoding.ASCII;       Console.WriteLine("Input Encoding Scheme = "+Console.InputEncoding);       Console.OutputEncoding = Encoding.ASCII;       Console.WriteLine("Output Encoding Scheme = "+Console.OutputEncoding);    } }OutputThis will produce the following output −

Read More

How to change the Input Encoding Scheme of the C# Console?

AmitDiwan
AmitDiwan
Updated on 14-Nov-2019 208 Views

To change the Input Encoding Scheme of the Console, use the Console.InputEncoding property.ExampleLet us see an example −using System; using System.Collections.Generic; using System.Threading.Tasks; using System.Linq; using System.Text; class Demo {    public static void Main (string[] args) {       Console.BackgroundColor = ConsoleColor.Blue;       Console.WriteLine("Background color changed = "+Console.BackgroundColor);       Console.ForegroundColor = ConsoleColor.Yellow;       Console.WriteLine("Foreground color changed = "+Console.ForegroundColor);       Console.InputEncoding = Encoding.ASCII;       Console.WriteLine("Input Encoding Scheme = "+Console.InputEncoding);       Console.CursorTop = 20;       Console.WriteLine("CursorTop = "+Console.CursorTop);    } }OutputThis will produce the following output −

Read More

MathF.Min() Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 14-Nov-2019 139 Views

The MathF.Min() method in C# returns the smallest of the two specified numbers.SyntaxFollowing is the syntax −public static float Min (float val1, float val2);Above, val1 is the first number, whereas val2 is the second number. Both of these numbers are compared.ExampleLet us now see an example to implement the MathF.Min() method −using System; public class Demo {    public static void Main(){       float val1 = 6.89f;       float val2 = 4.45f;       Console.WriteLine("Minimum Value = "+MathF.Min(val1, val2));    } }OutputThis will produce the following output −Minimum Value = 4.45ExampleLet us now see another ...

Read More

How to change the CursorTop of the Console in C#?

AmitDiwan
AmitDiwan
Updated on 14-Nov-2019 265 Views

To change the CursorTop of the Console in C#, use the Console.CursorTop propertyExampleLet us now see an example −using System; class Demo {    public static void Main (string[] args) {       Console.BackgroundColor = ConsoleColor.Blue;       Console.WriteLine("Background color changed = "+Console.BackgroundColor);       Console.ForegroundColor = ConsoleColor.Yellow;       Console.WriteLine("Foreground color changed = "+Console.ForegroundColor);       Console.CursorTop = 20;       Console.WriteLine("CursorTop = "+Console.CursorTop);    } }OutputThis will produce the following output −

Read More

Uri.IsHexDigit() Method in C#

AmitDiwan
AmitDiwan
Updated on 14-Nov-2019 143 Views

The Uri.IsHexDigit() method in C# determines whether a specified character is a valid hexadecimal digit.SyntaxFollowing is the syntax −public static bool IsHexDigit (char ch);Above, the parameter ch is the character to validate.ExampleLet us now see an example to implement the Uri.IsHexDigit() method −using System; public class Demo {    public static void Main(){       char ch = 'e';       Console.WriteLine("Character value = "+ch);       int res = Uri.FromHex(ch);       Console.WriteLine("Converted int value = "+res);       if(Uri.IsHexDigit(ch)) {          Console.WriteLine("Valid hexadecimal digit");       } else { ...

Read More

Console.SetBufferSize() Method in C#

AmitDiwan
AmitDiwan
Updated on 14-Nov-2019 324 Views

The Console.SetBufferSize() Method in C# is used to set the height and width of the screen buffer area to the specified values.SyntaxThe syntax is as follows −public static void SetBufferSize (int width, int height);Above, the parameter width is the width of the buffer area, whereas height is the height of the buffer area.ExampleLet us now see an example to implement the Console.SetBufferSize() Method in C# −using System; class Demo {    public static void Main (string[] args) {       Console.BackgroundColor = ConsoleColor.White;       Console.ForegroundColor = ConsoleColor.Red;       Console.SetBufferSize(400, 400);       while (true) ...

Read More

Console.ResetColor() Method in C#

AmitDiwan
AmitDiwan
Updated on 14-Nov-2019 419 Views

The Console.ResetColor() method in C# is used to set the foreground and background console colors to their defaults.SyntaxThe syntax is as follows −public static void ResetColor ();ExampleLet us now see an example to implement the Console.ResetColor() method in C# −using System; class Demo {    public static void Main (string[] args) {       Console.WriteLine ("At first, we have set colors here...After that, we will reset the colors to default.");       Console.BackgroundColor = ConsoleColor.White;       Console.ForegroundColor = ConsoleColor.Red;       Console.WriteLine ("Colors are set for this text");       Console.ResetColor();       ...

Read More
Showing 54701–54710 of 61,248 articles
Advertisements