MathF.Cos() Method in C# with Examples

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

63 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

49 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

Copying the Queue elements to one-dimensional array in C#

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

140 Views

Queue.CopyTo(T[], Int32) Method is used to copy the Queue elements to a 1-D array.ExampleLet us now see an example −using System; using System.Collections.Generic; public class Demo{    public static void Main(){       Queue queue = new Queue();       queue.Enqueue("K");       queue.Enqueue("T");       String[] strArr = new String[4];       strArr[0] = "One";       strArr[1] = "Two";       strArr[2] = "Three";       strArr[3] = "Four";       Console.WriteLine("Array elements: ");       for (int i = 0; i < strArr.Length; i++){       ... Read More

Console.SetBufferSize() Method in C#

AmitDiwan
Updated on 14-Nov-2019 06:03:30

147 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
Updated on 14-Nov-2019 05:58:19

184 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

Console.ReadLine() Method in C#

AmitDiwan
Updated on 14-Nov-2019 05:55:46

751 Views

The Console.ReadLine() method in C# is used to read the next line of characters from the standard input stream.SyntaxThe syntax is as follows −public static string ReadLine ();ExampleLet us now see an example to implement the Console.ReadLine() method in C# −using System; public class Demo{    public static void Main(){       string str;       Console.WriteLine("Enter any subject...");       str = Console.ReadLine();       Console.WriteLine("Entered subject = "+str);    } }OutputThis will produce the following output −Enter any subject... Entered subject = Maths

Console.Read() Method in C#

AmitDiwan
Updated on 14-Nov-2019 05:53:00

803 Views

The Console.Read() method in C# is used to read the next character from the standard input stream.SyntaxThe syntax is as follows −public static int Read ();ExampleLet us now see an example to implement the Console.Read() method in C# −using System; public class Demo{    public static void Main(){       int val;       Console.WriteLine("Enter a value");       val = Console.Read();       Console.WriteLine("Entered value: "+val);    } }OutputThis will produce the following output. Let’s sayEnter a value Entered value: 53

Console.MoveBufferArea() Method in C#

AmitDiwan
Updated on 14-Nov-2019 05:50:40

145 Views

The Console.MoveBufferArea() method in C# is used to copy a specified source area of the screen buffer to a specified destination area.SyntaxThe syntax is as follows −public static void MoveBufferArea (int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight, int targetLeft, int targetTop);Here, sourceLeft             The leftmost column of the source area.sourceTop             The topmost row of the source area.sourceWidth             The number of columns in the source area.sourceHeight            The number of rows in the source area.targetLeft            The leftmost ... Read More

Console.KeyAvailable() Property in C#

AmitDiwan
Updated on 14-Nov-2019 05:46:44

315 Views

The Console.KeyAvailable() property in C# is used to get a value indicating whether a key press is available in the input stream.SyntaxThe syntax is as follows −public static bool KeyAvailable { get; }ExampleLet us now see an example to implement the Console.KeyAvailable() property in C# −using System; using System.Threading; class Demo {    public static void Main (string[] args) {       ConsoleKeyInfo cs = new ConsoleKeyInfo();       do {          Console.WriteLine("Press a key to display; "+ "press the 'Q' key to quit.");          while (Console.KeyAvailable == false)Thread.Sleep(100);       ... Read More

Console Class in C#

AmitDiwan
Updated on 14-Nov-2019 05:41:46

1K+ Views

The Console class in C# is used to represent the standard input, output, and error streams for console applications.Let us see some examples of Console class properties in C# −Console.CursorLeft propertyTo change the CursorLeft of the Console in C#, use the Console.CursorLeft property.ExampleLet us 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.CursorLeft = 30;       Console.Write("CursorLeft position: "+Console.CursorLeft); ... Read More

Advertisements