Could someone please explain why this is happening?
var y = new int[]{1,2};
Console.WriteLine(y is uint[]); // false
Console.WriteLine(((object)y) is uint[]); // true
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In c# you can’t cast an
intto auint, so the first test fails because it is compiled to constant false.However, int->uint cast is allowed by the CLR. The second check cannot be deduced by the compiler and therefore must be calculated at runtime. As you’ve dodged compiler checks, the CLR allows it.