Csharp Articles - Page 89 of 258

UInt32.GetHashCode() Method in C# with Examples

AmitDiwan
Updated on 14-Nov-2019 06:56:00

144 Views

The UInt32.GetHashCode() method in C# is used to get the HashCode for the current UInt32 instance.SyntaxFollowing is the syntax −public override int GetHashCode ();ExampleLet us now see an example to implement the UInt32.GetHashCode() method −using System; public class Demo {    public static void Main(){       uint val1 = 100;       uint val2 = UInt16.MinValue;       Console.WriteLine("HashCode for val1 = "+val1.GetHashCode());       Console.WriteLine("HashCode for val2 = "+val2.GetHashCode());    } }OutputThis will produce the following output −HashCode for val1 = 100 HashCode for val2 = 0ExampleLet us now see another example to implement ... Read More

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

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

153 Views

Use the Console.WindowWidth Property to change the WindowWidth of the Console.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.WindowWidth = 30;       Console.Write("WindowWidth = "+Console.WindowWidth);    } } OutputThis will produce the following ... Read More

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

AmitDiwan
Updated on 14-Nov-2019 06:52:56

152 Views

Use the Console.WindowTop Property to change the WindowTop 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.WindowTop = 40;       Console.Write("WindowTop = "+Console.WindowTop);    } }OutputThis will produce the following ... Read More

UInt32.Equals() Method in C# with Examples

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

163 Views

The UInt32.Equals() method in C# returns a value indicating whether this instance is equal to a specified object or UInt32.SyntaxFollowing is the syntax −public override bool Equals (object ob); public bool Equals (uint ob);Above, the parameter ob for the 1st syntax is an object to compare to this instance and the parameter ob for the 2nd syntax is the 32-bit unsigned integer to compare to this instance.ExampleLet us now see an example to implement the UInt32.Equals() method −using System; public class Demo {    public static void Main(){       uint val1 = 52;       uint val2 ... Read More

UInt32.CompareTo() Method in C# with Examples

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

365 Views

The UInt32.CompareTo() method in C# is used to compare the current instance to a specified object or UInt32 and returns an indication of their relative values.SyntaxFollowing is the syntax −public int CompareTo (object val); public int CompareTo (uint val;Above, the Val for the 1st syntax is an object to compare. The Val for 2nd syntax is an unsigned integer to compare.The return value is 0 if the current instance is equal to value. It’s less than zero if the current instance is less than Val. The return value is more than zero if the current instance is greater than Val.ExampleLet ... Read More

How to change the WindowLeft of the Console

AmitDiwan
Updated on 14-Nov-2019 06:47:00

154 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 WindowHeight of the Console in C#?

AmitDiwan
Updated on 14-Nov-2019 06:44:04

162 Views

Use the Console.WindowHeight Property to change the WindowHeight of the Console.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.WindowHeight = 30;       Console.Write("WindowHeight = "+Console.WindowHeight);    } }OutputThis will produce the following output −Input ... Read More

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

AmitDiwan
Updated on 14-Nov-2019 06:43:18

446 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.Log10() Method in C# with Examples

AmitDiwan
Updated on 14-Nov-2019 06:40:51

97 Views

The MathF.Log10() method in C# is used to return the base 10 logarithm of a specified number.SyntaxFollowing is the syntax −public static float Log10 (float val);Above, Val is the number whose logarithm is to be calculated.ExampleLet us now see an example to implement the MathF.Log10() method −using System; public class Demo {    public static void Main(){       float val1 = 45.9f;       float val2 = -4.35f;       Console.WriteLine(MathF.Log10(val1));       Console.WriteLine(MathF.Log10(val2));    } }OutputThis will produce the following output −1.661813 NaNExampleLet us now see another example to implement the MathF.Log10() method −using ... Read More

MathF.Log() Method in C# with Examples

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

84 Views

The MathF.Log() method in C# is used to return the logarithm of a specified number.SyntaxFollowing is the syntax −public static float Log (float val);Above, Val is the specified number whose natural (base e) logarithm to be calculated.ExampleLet us now see an example to implement the MathF.Log() method −using System; public class Demo {    public static void Main(){       float val1 = 0.0f;       float val2 = 1.0f;       Console.WriteLine(MathF.Log(val1));       Console.WriteLine(MathF.Log(val2));    } }OutputThis will produce the following output −-Infinity 0ExampleLet us now see another example to implement the MathF.Log() method ... Read More

Advertisements