You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var dog = connection.Query<Dog>("select Age = @Age, Id = @Id", new { Age = (int?)null, Id = guid });
Why do you need to cast null to (int?) here?
I can understand the reason for the casting for the below one, but yours.
Main()
{
T.A(null);
}
public class T {
public static void A(string x) => Console.WriteLine("str");
public static void A(List<int> x) => Console.WriteLine("list");
}
The text was updated successfully, but these errors were encountered:
The new {...} is an anonymous type - the members need to have names and types. Without the cast (which is only a compile-time cast - it evaporates in the IL), the compiler wouldn't know what type to use for the Age member, and compilation would fail. Honestly, take away the cast and just try to compile it 👍
var dog = connection.Query<Dog>("select Age = @Age, Id = @Id", new { Age = (int?)null, Id = guid });
Why do you need to cast
null
to(int?)
here?I can understand the reason for the casting for the below one, but yours.
The text was updated successfully, but these errors were encountered: