Found 2587 Articles for Csharp

Char.GetNumericValue() Method in C#

AmitDiwan
Updated on 12-Nov-2019 09:32:15

590 Views

The Char.GetNumericValue() method in C# is used to convert the specified numeric Unicode character to a double-precision floating-point number.SyntaxFollowing is the syntax −public static double GetNumericValue (char ch);Above, the parameter ch is the Unicode character to convert.ExampleLet us now see an example to implement the Char.GetNumericValue() method −using System; public class Demo {    public static void Main(){       char val = 'm';       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));    } ... Read More

Char.GetHashCode() Method with Examples in C#

AmitDiwan
Updated on 12-Nov-2019 09:29:22

172 Views

The Char.GetHashCode() method in C# is used to return the hash code for the current instance.SyntaxFollowing is the syntax −public override int GetHashCode ();ExampleLet us now see an example to implement the Char.GetHashCode() method −using System; public class Demo {    public static void Main(){       char val = 'H';       bool res;       Console.WriteLine("Hashcode for val = "+val.GetHashCode());       res = val.Equals('d');       Console.WriteLine("Return Value = "+res);    } }OutputThis will produce the following output −Hashcode for val = 4718664 Return Value = FalseExampleLet us now see another example ... Read More

Char.Equals() Method in C#

AmitDiwan
Updated on 12-Nov-2019 09:27:06

3K+ Views

The Char.Equals() method in C# is used to return a value that indicates whether this instance is equal to a specified object or Char value.SyntaxFollowing is the syntax −public bool Equals (char ob);Above, ob is an object to compare to this instance.ExampleLet us now see an example to implement the Char.Equals() method −using System; public class Demo {    public static void Main(){       char val = 'A';       bool res;       res = val.Equals('A');       Console.WriteLine("Return Value = "+res);    } }OutputThis will produce the following output −Return Value = TrueExampleLet ... Read More

Decimal.ToByte() Method in C#

AmitDiwan
Updated on 12-Nov-2019 09:25:45

216 Views

The Decimal.ToByte() method in C# is used to convert the value of the specified Decimal to the equivalent 8-bit unsigned integer.SyntaxFollowing is the syntax −public static byte ToByte (decimal val);Above, Val is the decimal number to convert.ExampleLet us now see an example to implement the Decimal.ToByte() method −using System; public class Demo {    public static void Main(){       Decimal val1 = 6.59m;       Decimal val2 = 30.12m;       Decimal val3 = 69.34m;       Console.WriteLine("Decimal 1 = "+val1);       Console.WriteLine("Decimal 2 = "+val2);       Console.WriteLine("Decimal 3 = "+val3); ... Read More

Decimal.GetTypeCode() Method in C# with Examples

AmitDiwan
Updated on 12-Nov-2019 09:22:17

97 Views

The Decimal.GetTypeCode() method in C# is used to returns the TypeCode for value type Decimal.SyntaxFollowing is the syntax −public TypeCode GetTypeCode ();ExampleLet us now see an example to implement the Decimal.GetTypeCode() method −using System; public class Demo {    public static void Main(){       Decimal val = Decimal.MaxValue;       Console.WriteLine("Decimal Value = {0}", val);       Console.WriteLine("HashCode = {0}", (val.GetHashCode()) );       TypeCode type = val.GetTypeCode();       Console.WriteLine("TypeCode = "+type);    } }OutputThis will produce the following output −Decimal Value = 79228162514264337593543950335 HashCode = 1173356544 TypeCode = DecimalExampleLet us now see ... Read More

Decimal.GetHashCode() Method in C# with Examples

AmitDiwan
Updated on 12-Nov-2019 09:21:01

132 Views

The Decimal.GetHashCode() method in C# is used to return the hash code for the current instance.SyntaxFollowing is the syntax −public override int GetHashCode ();ExampleLet us now see an example to implement the Decimal.GetHashCode() method −using System; public class Demo {    public static void Main(){       Decimal val = 135269.38193M;       Console.WriteLine("Decimal Value = {0}", val);       Console.WriteLine("HashCode = {0}", (val.GetHashCode()) );    } }OutputThis will produce the following output −Decimal Value = 135269.38193 HashCode = 1328665595ExampleLet us now see another example to implement the Decimal.GetHashCode() method −using System; public class Demo {   ... Read More

Decimal.Ceiling() Method in C#

AmitDiwan
Updated on 12-Nov-2019 08:17:14

393 Views

The Decimal.Ceiling() method in C# is used to return the smallest integral value greater than or equal to the specified decimal number.SyntaxFollowing is the syntax −public static decimal Ceiling (decimal val);Above, Val is the decimal number.ExampleLet us now see an example to implement the Decimal.Ceiling() method −using System; public class Demo {    public static void Main(){       Decimal val1 = 12.85m;       Decimal val2 = 3.45m;       Console.WriteLine("Decimal 1 = "+val1);       Console.WriteLine("Decimal 2 = "+val2);       Console.WriteLine("Ceiling (val1) = "+Decimal.Ceiling(val1));       Console.WriteLine("Ceiling (val2) = "+Decimal.Ceiling(val2));   ... Read More

Decimal.Add() Method in C#

AmitDiwan
Updated on 12-Nov-2019 08:11:53

1K+ Views

The Decimal.Add() method in C# is used to add two specified Decimal values.SyntaxFollowing is the syntax −public static decimal Add (decimal val1, decimal val2);Above, va1 is the first decimal to add, whereas val2 is the second decimal to be added.ExampleLet us now see an example to implement the Decimal.Add() method −using System; public class Demo {    public static void Main(){       Decimal val1 = 3.07m;       Decimal val2 = 4.09m;       Console.WriteLine("Decimal 1 = "+val1);       Console.WriteLine("Decimal 2 = "+val2);       Decimal res = Decimal.Add(val1, val2);       ... Read More

DateTimeOffset.ToUnixTimeSeconds() Method in C#

AmitDiwan
Updated on 12-Nov-2019 08:10:19

572 Views

The DateTimeOffset.ToUnixTimeSeconds() method in C# is used to return the number of seconds that have elapsed since 1970-01-01T00:00:00Z.SyntaxFollowing is the syntax −public long ToUnixTimeSeconds ();ExampleLet us now see an example to implement the DateTimeOffset.ToUnixTimeSeconds() method −using System; public class Demo {    public static void Main() {       DateTimeOffset dateTimeOffset = new DateTimeOffset(1967, 11, 11, 6, 15, 45, new TimeSpan(3, 0, 0));       Console.WriteLine("DateTimeOffset = {0}", dateTimeOffset);       Console.WriteLine("Number of seconds: "+dateTimeOffset.ToUnixTimeSeconds());       DateTimeOffset res = dateTimeOffset.ToOffset(new TimeSpan(-5, 0, 0));       Console.WriteLine("DateTimeOffset (updated) = {0}", res);       Console.WriteLine("Number ... Read More

DateTimeOffset.ToUnixTimeMilliseconds() Method in C#

AmitDiwan
Updated on 12-Nov-2019 08:07:10

769 Views

The DateTimeOffset.ToUnixTimeMilliseconds() method in C# is used to return the number of milliseconds that have elapsed since 1970-01-01T00:00:00.000Z.SyntaxFollowing is the syntax −public long ToUnixTimeMilliseconds ();ExampleLet us now see an example to implement the DateTimeOffset.ToUnixTimeMilliseconds() method −using System; public class Demo {    public static void Main() {       DateTimeOffset dateTimeOffset = new DateTimeOffset(2019, 9, 10, 4, 20, 10, new TimeSpan(5, 0, 0));       Console.WriteLine("DateTimeOffset = {0}", dateTimeOffset);       Console.WriteLine("Number of milliseconds: "+dateTimeOffset.ToUnixTimeMilliseconds());       DateTimeOffset res = dateTimeOffset.ToOffset(new TimeSpan(-5, 0, 0));       Console.WriteLine("DateTimeOffset (updated) = {0}", res);       Console.WriteLine("Number ... Read More

Advertisements