Found 2628 Articles for Csharp

C# BitConverter.ToSingle() Method

AmitDiwan
Updated on 04-Dec-2019 11:31:52

1K+ Views

The BitConverter.ToSingle() method in C# is used to return a single-precision floating point number converted from four bytes at a specified position in a byte array.SyntaxThe syntax is as follows −public static float ToSingle (byte[] value, int begnIndex);Above, val is the byte array, whereas begnIndex is the beginning position within val.ExampleLet us now see an example − Live Demousing System; public class Demo {    public static void Main() {       byte[] arr = {0, 1, 2, 3, 5, 7, 10};       Console.WriteLine("Byte Array = {0} ",       BitConverter.ToString(arr));       for (int i ... Read More

Stack.Pop() Method in C#

AmitDiwan
Updated on 04-Dec-2019 11:28:00

725 Views

The Stack.Pop() method in C# is used to remove and return the object at the top of the Stack.SyntaxThe syntax is as follows −public virtual object Pop ();ExampleLet us now see an example − Live Demousing System; using System.Collections; public class Demo {    public static void Main() {       Stack stack = new Stack();       stack.Push("Inspiron");       stack.Push("Alienware");       stack.Push("Projectors");       stack.Push("Monitors");       stack.Push("XPS");       stack.Push("Laptop");       stack.Push("Notebook");       Console.WriteLine("Stack elements...");       foreach(string val in stack) {       ... Read More

Single.GetTypeCode Method in C# with Examples

AmitDiwan
Updated on 04-Dec-2019 11:21:08

59 Views

The Single.GetTypeCode() method in C# is used to return the TypeCode for value type Single.SyntaxThe syntax is as follows −public TypeCode GetTypeCode ();ExampleLet us now see an example − Live Demousing System; public class Demo {    public static void Main() {       float f1 = 15.3f;       float f2 = 35.9f;       Console.WriteLine("Value1 = "+f1);       Console.WriteLine("Hashcode for Value1 = "+f1.GetHashCode());       Console.WriteLine("TypeCode for Value1 = "+f1.GetTypeCode());       Console.WriteLine("Value2 = "+f2);       Console.WriteLine("Hashcode for Value2 = "+f2.GetHashCode());       Console.WriteLine("TypeCode for Value1 = "+f2.GetTypeCode());   ... Read More

C# Int16.ToString() Method

AmitDiwan
Updated on 04-Dec-2019 11:14:48

168 Views

The Int16.ToString() method in C# is used to convert the numeric value of this instance to its equivalent string representation.SyntaxThe syntax is as follows −public override string ToString (); public string ToString (string format);Above, the format parameter is a numeric format string.ExampleLet us now see an example − Live Demousing System; public class Demo {    public static void Main() {       short val1 = 10;       short val2 = 10;       Console.WriteLine("Value1 = "+val1.ToString());       Console.WriteLine("Value2 = "+val2.ToString());       Console.WriteLine("HashCode for value1 = "+val1.GetHashCode());       Console.WriteLine("HashCode for value2 ... Read More

C# Int32 Struct

AmitDiwan
Updated on 04-Dec-2019 11:11:49

475 Views

The Int32 Struct represents a 32-bit signed integer. It is an immutable value type that represents signed integers with values that range from negative 2, 147, 483, 648 through positive 2, 147, 483, 647.Following are the fields of the Int32 Struct −Sr.NoField & Description1MaxValueRepresents the largest possible value of an Int32. This field is constant.2MinValueRepresents the smallest possible value of an Int32. This field is constant.Following are some of the methods of the Int32 Struct −Sr.NoMethod & Description1CompareTo(Int32)Compares this instance to a specified 32-bit signed integer and returns an integer that indicates whether the value of this instance is less ... Read More

Double.GetTypeCode() Method in C#

AmitDiwan
Updated on 04-Dec-2019 11:09:39

18 Views

The Double.GetTypeCode() method in C# is used to return the TypeCode for value type Double.SyntaxThe syntax is as follows −public TypeCode GetTypeCode ();ExampleLet us now see an example − Live Demousing System; public class Demo {    public static void Main() {       double d = 15d;       Console.WriteLine("Double Value = "+d);       Console.WriteLine("HashCode of Double Value = "+d.GetHashCode());       TypeCode type = d.GetTypeCode();       Console.WriteLine("TypeCode of Double Value = "+type);    } }OutputThis will produce the following output −Double Value = 15 HashCode of Double Value = 1076756480 TypeCode of Double Value = DoubleExampleLet us now see another example − Live Demousing System; public ... Read More

Single.IsPositiveInfinity() Method in C# with Examples

AmitDiwan
Updated on 04-Dec-2019 11:06:47

82 Views

The Single.IsPositiveInfinity() method in C# is used to return a value indicating whether the specified number evaluates to positive infinity.SyntaxThe syntax is as follows −public static bool IsPositiveInfinity (float val);Above, the parameter val is a single-precision floating-point number.ExampleLet us now see an example − Live Demousing System; public class Demo {    public static void Main() {       float f1 = -25.0f/0.0f;       float f2 = 5.0f/0.0f;       Console.WriteLine("Value1 = "+f1);       Console.WriteLine("Hashcode for Value1 = "+f1.GetHashCode());       Console.WriteLine("TypeCode for Value1 = "+f1.GetTypeCode());       Console.WriteLine("Is Value1 value is positive ... Read More

C# Int16 Struct

AmitDiwan
Updated on 04-Dec-2019 11:02:25

353 Views

The Int16 Struct represents a 16-bit signed integer with values ranging from negative 32768 through positive 32767.Following are the fields of Int16 −Sr.NoField & Description1MaxValue − Represents the largest possible value of an Int16. This field is constant.2MinValue − Represents the smallest possible value of an Int16. This field is constant.Following are some of the methods −Sr.NoMethod & Description1CompareTo(Int16) − Compares this instance to a specified 16-bit signed integer and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the specified 16-bit signed integer.2CompareTo(Object) − Compares this instance to a specified object and ... Read More

Stack.Peek() Method in C#

AmitDiwan
Updated on 04-Dec-2019 10:46:40

817 Views

The Stack.Peek() method in C# is used to return the object at the top of the Stack without removing it.SyntaxThe syntax is as follows −public virtual object Peek ();ExampleLet us now see an example − Live Demousing System; using System.Collections; public class Demo {    public static void Main() {       Stack stack = new Stack();       stack.Push("Inspiron");       stack.Push("Alienware");       stack.Push("Projectors");       stack.Push("Monitors");       stack.Push("XPS");       stack.Push("Laptop");       stack.Push("Notebook");       Console.WriteLine("Stack elements...");       foreach(string val in stack) {     ... Read More

Stack.IsSynchronized Property in C#

AmitDiwan
Updated on 04-Dec-2019 10:32:07

48 Views

The Stack.IsSynchronized property in C# is used to get a value indicating whether access to the Stack is synchronized (thread safe).SyntaxThe syntax is as follows −public virtual bool IsSynchronized { get; }ExampleLet us now see an example − Live Demousing System; using System.Collections; public class Demo {    public static void Main() {       Stack stack = new Stack();       stack.Push("Inspiron");       stack.Push("Alienware");       stack.Push("Projectors");       stack.Push("Monitors");       stack.Push("XPS");       stack.Push("Laptop");       stack.Push("Notebook");       Console.WriteLine("Stack elements...");       foreach(string val in stack) ... Read More

Advertisements