By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,894 Members | 2,185 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,894 IT Pros & Developers. It's quick & easy.

Bug: incorrect warning message, Unreachable expression code detected

P: n/a
We've started converting some applications to the .NET 2.0 framework. When
compiling in VS 2005, I'm getting a warning on this line:
return (unitWidth != null ) ? unitWidth : new Unit("0px");

Looks valid to me, but this gives a warning with "new" underlined saying
"warning CS0429: Unreachable expression code detected".
Sep 28 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi,

It looks valid indeed.

I just wrote this in a project:

string G( string q)
{
return (q != null) ? q : new string('r', 12);
}

and it did compiled without warning.
Can you post the complete method?
"Don Burden" <no****@nomail.comwrote in message
news:ua**************@TK2MSFTNGP04.phx.gbl...
We've started converting some applications to the .NET 2.0 framework.
When compiling in VS 2005, I'm getting a warning on this line:
return (unitWidth != null ) ? unitWidth : new Unit("0px");

Looks valid to me, but this gives a warning with "new" underlined saying
"warning CS0429: Unreachable expression code detected".

Sep 28 '06 #2

P: n/a
"Don Burden" <no****@nomail.coma écrit dans le message de news:
ua**************@TK2MSFTNGP04.phx.gbl...

| We've started converting some applications to the .NET 2.0 framework.
When
| compiling in VS 2005, I'm getting a warning on this line:
| return (unitWidth != null ) ? unitWidth : new Unit("0px");
|
| Looks valid to me, but this gives a warning with "new" underlined saying
| "warning CS0429: Unreachable expression code detected".

My guess is that your code above this line will never allow unitWidth to be
null.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Sep 28 '06 #3

P: n/a
Hi,

Not even that, I changed my method to :

string G( )
{
string q = "sfsdf";
return (q != null) ? q : new string('r', 12);
}

and I still do not get a warning
There must be another error somewhere

--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Joanna Carter [TeamB]" <jo****@not.for.spamwrote in message
news:%2***************@TK2MSFTNGP02.phx.gbl...
"Don Burden" <no****@nomail.coma écrit dans le message de news:
ua**************@TK2MSFTNGP04.phx.gbl...

| We've started converting some applications to the .NET 2.0 framework.
When
| compiling in VS 2005, I'm getting a warning on this line:
| return (unitWidth != null ) ? unitWidth : new Unit("0px");
|
| Looks valid to me, but this gives a warning with "new" underlined saying
| "warning CS0429: Unreachable expression code detected".

My guess is that your code above this line will never allow unitWidth to
be
null.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer


Sep 28 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.