Found 2628 Articles for Csharp

Int64.MaxValue Field in C# with Examples

AmitDiwan
Updated on 13-Nov-2019 06:16:50

236 Views

The UInt64.MaxValue field in C# represents the maximum value of the 64-bit unsigned integer.SyntaxFollowing is the syntax −public const ulong MaxValue = 18446744073709551615;ExampleLet us now see an example to implement the UInt64.MaxValue field −using System; public class Demo {    public static void Main(){       ulong val1 = 879879879;       ulong val2 = 464556565;       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

Int64.GetTypeCode Method in C# with Examples

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

68 Views

The Int64.GetTypeCode() method in C# is used to return the TypeCode for value type Int64.SyntaxFollowing is the syntax −public TypeCode GetTypeCode ();ExampleLet us now see an example to implement the Int64.GetTypeCode() method −using System; public class Demo {    public static void Main(){       long val1 = 0;       long val2 = Int64.MaxValue;       Console.WriteLine("Value1 = "+val1);       Console.WriteLine("Value2 = "+val2);       Console.WriteLine("Are they equal? = "+val1.Equals(val2));       Console.WriteLine("Value1 (HashCode) = "+val1.GetHashCode());       Console.WriteLine("Value2 (HashCode) = "+val2.GetHashCode());       TypeCode type1 = val1.GetTypeCode();     ... Read More

Decimal.Subtract() Method in C#

AmitDiwan
Updated on 13-Nov-2019 06:12:52

446 Views

The Decimal.Subtract() method in C# is used to subtract two specified Decimal values.SyntaxFollowing is the syntax −public static decimal Subtract (decimal val1, decimal val2);Above, va1 is the minuend, whereas val2 is the subtrahend.ExampleLet us now see an example to implement the Decimal.Subtract() method −using System; public class Demo {    public static void Main(){       Decimal val1 = 3.45m;       Decimal val2 = 2.35m;       Console.WriteLine("Decimal 1 = "+val1);       Console.WriteLine("Decimal 2 = "+val2);       Decimal res = Decimal.Subtract(val1, val2);       Console.WriteLine("Result (Subtract) = "+res);    } }OutputThis ... Read More

Decimal.Round() Method in C#

AmitDiwan
Updated on 13-Nov-2019 06:08:14

8K+ Views

The Decimal.Round() method in C# is used to round a value to the nearest integer or specified number of decimal places.SyntaxFollowing is the syntax −public static decimal Round (decimal d); public static decimal Round (decimal d, int decimals); public static decimal Round (decimal d, MidpointRounding mode); public static decimal Round (decimal d, int decimals, MidpointRounding mode);ExampleLet us now see an example to implement the Decimal.Round() method −using System; public class Demo {    public static void Main(){       Decimal val1 = 9.00m;       Decimal val2 = 15.29m;       Decimal val3 = 394949845.14245M;     ... Read More

Decimal.Remainder() Method in C#

AmitDiwan
Updated on 13-Nov-2019 06:03:17

166 Views

The Decimal.Remainder() method in C# is used to calculate the remainder after dividing two Decimal values.SyntaxFollowing is the syntax −public static decimal Remainder (decimal val1, decimal val2);Above, val1 is the dividend, whereas val2 is the divisor.ExampleLet us now see an example to implement the Decimal.Remainder() method −using System; public class Demo {    public static void Main(){       Decimal val1 = 45.15m;       Decimal val2 = 15.15m;       Console.WriteLine("Decimal 1 = "+val1);       Console.WriteLine("Decimal 2 = "+val2);       Console.WriteLine("After Division = "+(Decimal.Divide(val1, val2)));       Console.WriteLine("Remainder = "+(Decimal.Remainder(val1, val2))); ... Read More

Decimal.Negate() Method in C#

AmitDiwan
Updated on 13-Nov-2019 05:58:59

585 Views

The Decimal.Negate() method in C# is used to return the result of multiplying the specified Decimal value by negative one.SyntaxFollowing is the syntax −public static decimal Negate (decimal val);Above, Val is the value to negate.ExampleLet us now see an example to implement the Decimal.Negate() method −using System; public class Demo {    public static void Main(){       Decimal val = 3972.491M;       Console.WriteLine("Decimal Value = {0}", val);       Console.WriteLine("HashCode = {0}", (val.GetHashCode()) );       TypeCode type = val.GetTypeCode();       Console.WriteLine("TypeCode = "+type);       Decimal res = Decimal.Negate(val);   ... Read More

Decimal.Multiply() Method in C#

AmitDiwan
Updated on 13-Nov-2019 05:56:51

987 Views

The Decimal.Add() method in C# is used to multiply two specified Decimal values.SyntaxFollowing is the syntax −public static decimal Multiply (decimal val1, decimal val2);Above, va1 is the multiplicand, whereas val2 is the multiplier.ExampleLet us now see an example to implement the Decimal.Multiply() method −using System; public class Demo {    public static void Main(){       Decimal val1 = 3.45m;       Decimal val2 = 2.35m;       Console.WriteLine("Decimal 1 = "+val1);       Console.WriteLine("Decimal 2 = "+val2);       Decimal res = Decimal.Multiply(val1, val2);       Console.WriteLine("Result (Multiplication) = "+res);    } }OutputThis ... Read More

Int64.GetHashCode Method in C# with Examples

AmitDiwan
Updated on 13-Nov-2019 05:54:55

100 Views

The Int64.GetHashCode() method in C# is used to return the hash code for this instance.SyntaxFollowing is the syntax −public override int GetHashCode ();ExampleLet us now see an example to implement the Int64.GetHashCode() method −using System; public class Demo {    public static void Main(){       long val1 = 8768768768;       long val2 = 7889765555;       Console.WriteLine("Value1 = "+val1);       Console.WriteLine("Value2 = "+val2);       Console.WriteLine("Are they equal? = "+val1.Equals(val2));       Console.WriteLine("Value1 (HashCode) = "+val1.GetHashCode());       Console.WriteLine("Value2 (HashCode) = "+val2.GetHashCode());    } }OutputThis will produce the following output ... Read More

Int64.Equals Method in C# with Examples

AmitDiwan
Updated on 13-Nov-2019 05:52:48

83 Views

The Int64.Equals() method in C# is used to return a value indicating whether this instance is equal to a specified object or Int64.SyntaxFollowing is the syntax −public bool Equals (long ob); public override bool Equals (object ob);Above, the parameter ob is an Int64 value to compare to this instance, whereas the parameter ob is an object to compare with this instance.ExampleLet us now see an example to implement the Int64.Equals() method −using System; public class Demo {    public static void Main(){       long val1 = 150;       long val2 = 240;       Console.WriteLine("Value1 ... Read More

Int64.CompareTo Method in C# with Examples

AmitDiwan
Updated on 13-Nov-2019 05:50:43

151 Views

The Int64.CompareTo() method in C# is used to compare this instance to a specified object or Int64 and returns an indication of their relative values.SyntaxFollowing is the syntax −public int CompareTo (long val); public int CompareTo (object val);Above, in the 1st syntax, the value Val is an integer to compare. The Val in the 2nd syntax is an object to compare.ExampleLet us now see an example to implement the Int64.CompareTo() method −using System; public class Demo {    public static void Main(){       long val1 = 20;       long val2 = 18;       Console.WriteLine("Value ... Read More

Advertisements