Found 2587 Articles for Csharp

MathF.Atanh() Method in C# with Examples

AmitDiwan
Updated on 12-Nov-2019 10:21:29

115 Views

The MathF.Atanh() method in C# returns the hyperbolic arc-tangent of a floating-point value.SyntaxFollowing is the syntax −public static float Atanh (float val);ExampleLet us now see an example to implement the MathF.Atanh() method −using System; public class Demo {    public static void Main(){       float val1 = 25f;       float val2 = 15f;       Console.WriteLine("Return value (val1) = "+(MathF.Atanh(val1)));       Console.WriteLine("Return value (val2) = "+(MathF.Atanh(val2)));    } }OutputThis will produce the following output −Return value (val1) = NaN Return value (val2) = NaNExampleLet us now see another example to implement the MathF.Atanh() ... Read More

UInt16.ToString Method in C# with Examples

AmitDiwan
Updated on 12-Nov-2019 09:57:26

162 Views

The UInt16.ToString() method in C# is used to convert the numeric value of the current UInt16 instance to its equivalent string representation.SyntaxFollowing is the syntax −public override string ToString();ExampleLet us now see an example to implement the UInt16.ToString() method −using System; public class Demo {    public static void Main(){       ushort val1 = 100;       ushort val2 = 80;       Console.WriteLine("Value1 (String representation) = "+val1.ToString());       Console.WriteLine("Value2 (String representation) = "+val2.ToString());       bool res = val1.Equals(val2);       Console.WriteLine("Return value (comparison) = "+res);       if (res) ... Read More

UInt16.MinValue Field in C# with Examples

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

159 Views

The UInt16.MinValue field in C# represents the minimum possible value of the 16-bit unsigned integer.SyntaxFollowing is the syntax −public const ushort MinValue = 0;ExampleLet us now see an example to implement the UInt16.MinValue field −using System; public class Demo {    public static void Main(){       ushort val1 = 23;       ushort val2 = 0;       Console.WriteLine("Value1 = "+val1);       Console.WriteLine("Value2 = "+val2);       Console.WriteLine("HashCode for value1 = "+val1.GetHashCode());       Console.WriteLine("HashCode for value2 = "+val2.GetHashCode());       Console.WriteLine("Are they equal? = "+(val1.Equals(val2)));       TypeCode type1 ... Read More

MathF.Sign() Method in C# with Examples

AmitDiwan
Updated on 12-Nov-2019 09:53:33

325 Views

The MathF.Sign() method in C# returns an integer specifying the sign of the number.SyntaxFollowing is the syntax −public static int Sign (float val);Above, Val is the floating-point number whose sign is to be calculated.The return value is 0 if Val is zero. It’s -1 if the value is less than zero and 1 if the value is greater than zero.ExampleLet us now see an example to implement the MathF.Sign() method −using System; public class Demo {    public static void Main(){       float val1 = 10.23898f;       float val2 = -20.878788f;       Console.WriteLine("MathF.Sign(val1) = ... Read More

MathF.Round() Method in C# with Examples

AmitDiwan
Updated on 12-Nov-2019 09:52:10

3K+ Views

The MathF.Round() method in C# is used to round a value to the nearest integer or to the particular number of fractional digits.SyntaxFollowing is the syntax −public static float Round (float x); public static float Round (float x, int digits); public static float Round (float x, int digits, MidpointRounding mode); public static float Round (float x, MidpointRounding mode);ExampleLet us now see an example to implement the MathF.Round() method −using System; public class Demo {    public static void Main(){       float val1 = 15.20f;       float val2 = 3.10f;       Console.WriteLine("Rounded (val1) = "+MathF.Round(val1)); ... Read More

Decimal.ToInt16() Method in C#

AmitDiwan
Updated on 12-Nov-2019 09:49:38

84 Views

The Decimal.ToInt16() method in C# is used to convert the value of the specified Decimal to the equivalent 16-bit signed integer.SyntaxFollowing is the syntax −public static short ToInt16 (decimal val);Above, Val is the decimal number to convert.ExampleLet us now see an example to implement the Decimal.ToInt16() method −using System; public class Demo {    public static void Main(){       Decimal val1 = -3.578m;       Decimal val2 = 9.352m;       Console.WriteLine("Decimal 1 = "+val1);       Console.WriteLine("Decimal 2 = "+val2);       short res1 = Decimal.ToInt16(val1);       short res2 = Decimal.ToInt16(val2); ... Read More

Decimal.ToDouble() Method in C#

AmitDiwan
Updated on 12-Nov-2019 09:46:44

138 Views

The Decimal.ToDouble() method in C# is used to convert the value of the specified Decimal to the equivalent double-precision floating-point number.SyntaxFollowing is the syntax −public static double ToDouble (decimal val);Above, Val is the decimal number to convert.ExampleLet us now see an example to implement the Decimal.ToDouble() method −using System; public class Demo {    public static void Main(){       Decimal val1 = -0.22m;       Decimal val2 = -0.01m;       Console.WriteLine("Decimal 1 = "+val1);       Console.WriteLine("Decimal 2 = "+val2);       Double res1 = Decimal.ToDouble(val1);       Double res2 = Decimal.ToDouble(val2); ... Read More

Int16.CompareTo() Method in C#

AmitDiwan
Updated on 12-Nov-2019 09:38:49

6K+ Views

The Int16.CompareTo() method in C# is used to compare this instance to a specified object or another Int16 instance 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 object or the other Int16 instance.SyntaxFollowing is the syntax −public int CompareTo (short val); public int CompareTo (object val);Above, in the 1st syntax, the value val is an integer to compare, whereas Val in the 2nd syntax is an object to compare.The return value is less than zero if the current instance is less than the ... Read More

Char.GetUnicodeCategory(String, Int32) Method with Examples in C#

AmitDiwan
Updated on 12-Nov-2019 09:36:07

200 Views

The Char.GetUnicodeCategory(String, Int32) method in C# categorizes the character at the specified position in a specified string into a group identified by one of the UnicodeCategory values.SyntaxFollowing is the syntax −public static System.Globalization.UnicodeCategory GetUnicodeCategory (string str, int index);Above, str is a string, whereas the index is the character position in str.ExampleLet us now see an example to implement the Char.GetUnicodeCategory(String, Int32) method −using System; using System.Globalization; public class Demo {    public static void Main(){       string val = "amit";       UnicodeCategory unicode = Char.GetUnicodeCategory(val, 2);       Console.WriteLine("The value at specific index = "+unicode); ... Read More

Char.GetTypeCode() Method with Examples in C#

AmitDiwan
Updated on 12-Nov-2019 09:34:13

125 Views

The Char.GetTypeCode() method in C# is used to return the TypeCode for value type Char.SyntaxFollowing is the syntax −public TypeCode GetTypeCode ();ExampleLet us now see an example to implement the Char.GetTypeCode() method −using System; public class Demo {    public static void Main(){       char val = '5';       bool res;       Console.WriteLine("Hashcode for val = "+val.GetHashCode());       res = val.Equals('m');       Console.WriteLine("Return Value = "+res);       Console.WriteLine("Numeric Value = "+Char.GetNumericValue(val));       TypeCode type = val.GetTypeCode();       Console.WriteLine("Type = "+type);    } }OutputThis will ... Read More

Advertisements