Server Side Programming Articles - Page 2115 of 2650

UInt16.GetHashCode() Method in C# with Examples

AmitDiwan
Updated on 05-Nov-2019 07:59:29

126 Views

The UInt16.GetHashCode() method in C# is used to get the HashCode for the current UInt16 instance.SyntaxFollowing is the syntax −public override int GetHashCode ();ExampleLet us now see an example to implement the UInt16.GetHashCode() method −using System; public class Demo {    public static void Main(){       ushort val1 = 100;       ushort 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

Tuple Class in C#

AmitDiwan
Updated on 05-Nov-2019 07:57:04

149 Views

The Tuple class represents a 2-tuple, which is called pair. A tuple is a data structure that has a sequence of elements.It is used in −Easier access to a data set.Easier manipulation of a data set.To represent a single set of data.To return multiple values from a methodTo pass multiple values to a methodIt has two properties −Item1 − Get the value of the current Tuple object's first component.Item2 − Get the value of the current Tuple object's second component.ExampleLet us now see an example to implement the 2-tuple in C# −using System; public class Demo {    public static ... Read More

UInt16.Equals Method in C# with Examples

AmitDiwan
Updated on 05-Nov-2019 07:54:23

138 Views

The UInt16.Equals() method in C# returns a value indicating whether this instance is equal to a specified object or UInt16.SyntaxFollowing is the syntax −public override bool Equals (object ob); public bool Equals (ushort 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 16-bit unsigned integer to compare to this instance.ExampleLet us now see an example to implement the UInt16.Equals() method −using System; public class Demo {    public static void Main(){       ushort val1 = 52;       ushort val2 ... Read More

MathF.Truncate() Method in C# with Examples

AmitDiwan
Updated on 05-Nov-2019 07:47:44

389 Views

The MathF.Truncate() method in C# is used to calculate an integral part of a specified single number or single-precision floating-point number.SyntaxFollowing is the syntax −public static float Truncate (float val);Above, Val is the specified number to be truncatedExampleLet us now see an example to implement the MathF.Truncate() method −using System; public class Demo {    public static void Main(){       float val1 = float.PositiveInfinity;       float val2 = float.NegativeInfinity;       Console.WriteLine("MathF.Truncate(val1) = "+MathF.Truncate(val1));       Console.WriteLine("MathF.Truncate(val2) = "+MathF.Truncate(val2));    } }OutputThis will produce the following output −MathF.Truncate(val1) = Infinity MathF.Truncate(val2) = -InfinityExampleLet us ... Read More

MathF.Tanh() Method in C# with Examples

AmitDiwan
Updated on 05-Nov-2019 07:44:22

145 Views

The MathF.Tanh() method in C# returns the hyperbolic tangent of a given single value argument.SyntaxFollowing is the syntax −public static float Tanh (float val);Above, Val is the is number whose hyperbolic tangent is to be returned.ExampleLet us now see an example to implement the MathF.Tanh() method −using System; public class Demo {    public static void Main(){       float val1 = 10f;       float val2 = float.NaN;       Console.WriteLine("MathF.Tanh(val1) = "+MathF.Tanh(val1));       Console.WriteLine("MathF.Tanh(val2) = "+MathF.Tanh(val2));    } }OutputThis will produce the following output −MathF.Tanh(val1) = 1 MathF.Tanh(val2) = NaNExampleLet us now see ... Read More

MathF.Tan() Method in C# with Examples

AmitDiwan
Updated on 05-Nov-2019 07:42:02

166 Views

The MathF.Tan() method in C# is used to return the tangent of a given float value argument.SyntaxFollowing is the syntax −public static float Tan (float val);Above, Val is the angle whose tangent is to be returned.ExampleLet us now see an example to implement the MathF.Tan() method −using System; public class Demo {    public static void Main(){       float val1 = 10f;       float val2 = float.NaN;       Console.WriteLine("MathF.Tan(val1) = "+MathF.Tan(val1));       Console.WriteLine("MathF.Tan(val2) = "+MathF.Tan(val2));    } }OutputThis will produce the following output −MathF.Tan(val1) = 0.6483608 MathF.Tan(val2) = NaNExampleLet us now see ... Read More

Convert.ToBase64String() Method in C#

AmitDiwan
Updated on 05-Nov-2019 07:37:58

1K+ Views

The Convert.ToBase64String() method in C# is used to convert the value of an array of 8-bit unsigned integers to its equivalent string representation that is encoded with base-64 digits.SyntaxFollowing is the syntax −public static string ToBase64String (byte[] arr);Above, arr is an array of 8-bit unsigned integers.ExampleLet us now see an example to implement the Convert.ToBase64String() method −Using System; public class Demo {    public static void Main(){       byte[] val1 = {5, 10, 15, 20, 25, 30};       string str = Convert.ToBase64String(val1);       Console.WriteLine("Base 64 string: '{0}'", str);       byte[] val2 = ... Read More

Convert.ToBase64CharArray() Method in C#

AmitDiwan
Updated on 05-Nov-2019 07:36:26

280 Views

The Convert.ToBase64CharArray() method in C# is used to convert a subset of an 8-bit unsigned integer array to an equivalent subset of a Unicode character array encoded with base-64 digits.SyntaxFollowing is the syntax −public static int ToBase64CharArray (byte[] arr, int offsetIn, int length, char[] outArray, int offsetOut);Here, arr − An input array of 8-bit unsigned integers.offsetIn − A position within arr.length − The number of elements of arr to convert.outArray − An output array of Unicode characters.offsetOut − A position within outArray.ExampleLet us now see an example to implement the Convert.ToBase64CharArray() method −using System; public class Demo {    public ... Read More

Convert.FromBase64String(String) Method in C#

AmitDiwan
Updated on 05-Nov-2019 07:23:41

3K+ Views

The Convert.FromBase64String(String) method in C# converts the specified string, which encodes binary data as base-64 digits, to an equivalent 8-bit unsigned integer array.SyntaxFollowing is the syntax −public static byte[] FromBase64String (string str);Above, the parameter str is the string to convert.ExampleLet us now see an example to implement the Convert.FromBase64String(String) method −using System; public class Demo {    public static void Main(){       byte[] val1 = {5, 10, 15, 20, 25, 30};       string str = Convert.ToBase64String(val1);       Console.WriteLine("Base 64 string: '{0}'", str);       byte[] val2 = Convert.FromBase64String(str);       Console.WriteLine("Converted byte ... Read More

CharEnumerator.ToString() Method in C#

AmitDiwan
Updated on 05-Nov-2019 07:20:36

66 Views

The CharEnumerator.ToString() method in C# gets a string that represents the current object.SyntaxFollowing is the syntax -public virtual string ToString();ExampleLet us now see an example to implement the CharEnumerator.ToString() method −using System; public class Demo {    public static void Main(){       string strNum = "This is it!";       CharEnumerator ch = strNum.GetEnumerator();       Console.WriteLine("HashCode = "+ch.GetHashCode());       Console.WriteLine("Get the Type = "+ch.GetType());       Console.WriteLine("String representation = "+ch.ToString());       while (ch.MoveNext())          Console.Write(ch.Current + " ");       ch.Reset();       Console.WriteLine();   ... Read More

Advertisements