Change Input Encoding Scheme of the C# Console

AmitDiwan
Updated on 14-Nov-2019 06:27:24

182 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 −

Mathf Min Method in C# with Examples

AmitDiwan
Updated on 14-Nov-2019 06:25:24

91 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

Mathf.Max Method in C# with Examples

AmitDiwan
Updated on 14-Nov-2019 06:23:54

70 Views

The MathF.Max() method in C# returns the larger of the two specified numbers.SyntaxFollowing is the syntax −public static float Max (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.Max() method −using System; public class Demo {    public static void Main(){       float val1 = 11.89f;       float val2 = 55.67f;       Console.WriteLine("Maximum Value = "+MathF.Max(val1, val2));    } }OutputThis will produce the following output −Maximum Value = 55.67ExampleLet us now see another ... Read More

Change CursorTop of the Console in C#

AmitDiwan
Updated on 14-Nov-2019 06:21:53

223 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 −

Change BufferHeight of the Console in C#

AmitDiwan
Updated on 14-Nov-2019 06:19:06

137 Views

To change the BufferHeight of the Console, use the Console.BufferHeight property in C#.ExampleLet us now see an example −using System; class Demo {    public static void Main (string[] args) {       Console.BufferHeight = 200;       Console.WriteLine("Buffer Height = "+Console.BufferHeight);    } }OutputThis will produce the following output −Buffer Height = 200

Change Background Color of Text in C# Console

AmitDiwan
Updated on 14-Nov-2019 06:16:05

2K+ Views

To change the background color of text in Console, use the Console.BackgroundColor Property in C#.ExampleLet 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);    } }OutputThis will produce the following output −

Mathf.Exp Method in C# with Examples

AmitDiwan
Updated on 14-Nov-2019 06:13:38

103 Views

The MathF.Exp() method in C# returns the raised to the specified power.SyntaxFollowing is the syntax −public static float Exp (float val);Above, Val is the floating-point number.ExampleLet us now see an example to implement the MathF.Exp() method −using System; class Demo {    public static void Main(){       float val = 90f;       float res = MathF.Exp(val);       Console.WriteLine("MathF.Exp() = "+res);    } }OutputThis will produce the following output −MathF.Exp() = InfinityExampleLet us now see another example to implement the MathF.Exp() method −using System; class Demo {    public static void Main(){       ... Read More

MathF.Cosh Method in C# with Examples

AmitDiwan
Updated on 14-Nov-2019 06:11:16

56 Views

The MathF.Cosh() method in C# is used to return the hyperbolic cosine of a floating-point value.SyntaxFollowing is the syntax −public static float Cosh (float val);Above, Val is the floating-point number.ExampleLet us now see an example to implement the MathF.Cosh() method −using System; class Demo {    public static void Main(){       float val = 45.0f;       float res = MathF.Cosh(val);       Console.WriteLine("Cosh = "+res);    } }OutputThis will produce the following output −Cosh = 1.746714E+19ExampleLet us now see another example to implement the MathF.Cosh() method −using System; class Demo {    public static void ... Read More

MathF Cos Method in C# with Examples

AmitDiwan
Updated on 14-Nov-2019 06:10:02

130 Views

The MathF.Cos() method in C# returns the cosine of a given float value argument.SyntaxFollowing is the syntax −public static float Cos (float val);Above, Val is the floating-point value.ExampleLet us now see an example to implement the MathF.Cos() method −using System; class Demo {    public static void Main(){       float val1 = 70f;       float res = (val1 * (MathF.PI)) / 180;       Console.WriteLine(MathF.Cos(res));    } }OutputThis will produce the following output −0.34202ExampleLet us now see another example to implement the MathF.Cos() method −using System; class Demo {    public static void Main(){   ... Read More

uri-isHexDigit Method in C#

AmitDiwan
Updated on 14-Nov-2019 06:07:36

118 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

Advertisements