BlazingFox

Has anyone else experienced this The following code now generates a warning saying "Unreachable code detected". This is new since applying VS 2005 SP1. The warning is given on the throw statement below.

public DateTime CurrentTime
{
set
{
if (value == null)
{
throw new ArgumentNullException(); // Error here.
}
currentTime = value;
}
}

It implies that the value passed in to the setter could never be null which is obviously not true. I just started getting this warning after upgrading with SP1.



Re: Visual C# IDE New bug added in VS 2005 SP1? "Unreachable code detected" warning.

Mike Danes

DateTime type is a value type and obviously cannot be null !





Re: Visual C# IDE New bug added in VS 2005 SP1? "Unreachable code detected" warning.

BlazingFox

Thanks! I always forget that. I split my time between Java and C# and always forget that DateTime is a struct.