Last active
January 2, 2016 23:59
-
-
Save VladimirReshetnikov/8380121 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
// What argument do you need to provide to this method so that it returns true? | |
public static bool AreYouNuts<T>(T[] array) | |
{ | |
if (array == null || array.Length == 0) | |
return false; | |
var local = (T[]) array.Clone(); | |
var x = local[0]; | |
var y = local.GetValue(0); | |
return x.GetType() != y.GetType(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is a CLR rule. See Ecma-335, Partition I, 8.7.1 Assignment compatibility for signature types:
...
7. T is a zero-based rank-1 array V[], and U is IList, and V is array-element-compatible-with W.
...
[Note: in other words, array-element-compatible-with extends compatible-with but is agnostic
with respect to enumerations and integral signed-ness. end note]