Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int GetLargestValue(int[] values)
- {
- try {
- Array.Sort(values);
- return values[values.Length - 1];
- }
- catch (Exception){ return -1;}
- }
- public int GetLargestValue(int[] values)
- {
- if(values == null)
- return -1;
- if(values.Length < 1)
- return -1;
- int highestValue = values[0];
- foreach(int value in values)
- if(value > highestValue)
- highestValue = value;
- return highestValue;
- }
Add Comment
Please, Sign In to add comment