CSharp examples for System:Math Number
Max among values
// Copyright (c) Cragon. All rights reserved. using System;//from w w w . j av a 2 s.com public class Main{ //--------------------------------------------------------------------- public static int Max(params int[] values) { int length = values.Length; if (length == 0) { return 0; } int num2 = values[0]; for (int i = 1; i < length; i++) { if (values[i] > num2) { num2 = values[i]; } } return num2; } //--------------------------------------------------------------------- public static float Max(params float[] values) { int length = values.Length; if (length == 0) { return 0f; } float num2 = values[0]; for (int i = 1; i < length; i++) { if (values[i] > num2) { num2 = values[i]; } } return num2; } //--------------------------------------------------------------------- public static ulong Max(ulong a, ulong b) { return ((a <= b) ? b : a); } //--------------------------------------------------------------------- public static long Max(long a, long b) { return ((a <= b) ? b : a); } //--------------------------------------------------------------------- public static uint Max(uint a, uint b) { return ((a <= b) ? b : a); } //--------------------------------------------------------------------- public static int Max(int a, int b) { return ((a <= b) ? b : a); } //--------------------------------------------------------------------- public static ushort Max(ushort a, ushort b) { return ((a <= b) ? b : a); } //--------------------------------------------------------------------- //public static Int8 Max(Int8 a, Int8 b) //{ // return ((a <= b) ? b : a); //} //--------------------------------------------------------------------- //public static UInt8 Max(UInt8 a, UInt8 b) //{ // return ((a <= b) ? b : a); //} //--------------------------------------------------------------------- public static short Max(short a, short b) { return ((a <= b) ? b : a); } //--------------------------------------------------------------------- public static float Max(float a, float b) { return ((a <= b) ? b : a); } }