What do Min(), Max() & Sum() methods return if the elements are of a non-numeric type? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What do Min(), Max() & Sum() methods return if the elements are of a non-numeric type?

4th Dec 2016, 7:56 AM
Paul Shaddick
Paul Shaddick - avatar
3 Answers
+ 4
Min() returns ths string/character with the lowest ASCII value. Max returns the one with the highest. Sum() doesn't have an overload for string[] or char[]. I'm not sure what they would do with any other types, though...
4th Dec 2016, 8:33 AM
Tamra
Tamra - avatar
+ 1
are you sure that the language is c#? in PHP the return of sum, is 0, if all array elements are non-numeric.
4th Dec 2016, 8:11 AM
Nahuel
Nahuel - avatar
0
Yes these are defined array methods in C#. I have done some experiments with char arrays. Min and Max are defined by unicode sort order, but Sum produces a compilation error.
4th Dec 2016, 8:45 AM
Paul Shaddick
Paul Shaddick - avatar