C# Math Max(Int64, Int64)

Description

Math Max(Int64, Int64) returns the larger of two 64-bit signed integers.

Syntax

Math.Max(Int64, Int64) has the following syntax.


public static long Max(
  long val1,
  long val2
)

Parameters

Math.Max(Int64, Int64) has the following parameters.

  • val1 - The first of two 64-bit signed integers to compare.
  • val2 - The second of two 64-bit signed integers to compare.

Returns

Math.Max(Int64, Int64) method returns Parameter val1 or val2, whichever is larger.

Example

The following example demonstrates how to use the Max method to return and display the greater of two variables.


using System;/*w  w  w .  ja v a  2  s.  co m*/

class Sample 
{
    public static void Main() 
    {
        long     xLong1    = -4,   xLong2    = 54;
        Console.WriteLine(Math.Max(xLong1, xLong2));
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version