I just figured out, that it is possible to use the is-keyword
in C# for a null check on nullable stucts. I think it looks quite clean and is good to understand, but is it also performant? Does the interpreter has to double cast it or is it okay that way?
static void Main(string[] args)
{
DateTime? test = null;
PrintDT(test);//wont print
test = DateTime.Now;
PrintDT(test);//will print
}
private static void PrintDT(DateTime? dt)
{
if (dt is DateTime a)
Console.WriteLine(a);
}