473,383 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Bug: incorrect warning message, Unreachable expression code detected

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
3 3281
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
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Steve Jorgensen | last post by:
Microsoft acknowledges a bug with this, but the bug is worse than they say. It turns out that if you use the Like operator without a wildcard on a snapshot type recordset, all sorts of wierd,...
3
by: Filip Strugar | last post by:
...or where should I post it if this is not the right place? Goes like this: I've got a following method in a class DataSource: public IHeightmapSampler GetSampler(ushort maxSmpX,...
19
by: Jerry | last post by:
I managed to narrow this down to a very simple expression. try this: private void Bug() { bool b = false; Test(3, (b || b) && b && !b); } private void Works() {
6
by: J.D. Herron via .NET 247 | last post by:
Just wanted to throw out there a VC7.1 compiler bug when usingwarning level 4. The following code will demonstrate theproblem: class TestClass { public: // Initialized float member,...
6
by: dfetrow410 | last post by:
Can I do this in an if statement? public string getClass() { counta = counta + 1; if (counta < 2 ) {
8
by: teddysnips | last post by:
I'm new to C# - recent background mainly ASP.NET with VB.NET. Anyhoot, I needed to create a C# statement analogous to VB's IIf: VB.NET Dim e As Boolean e = IIf((CInt(MyVariable) 0), True,...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 385 open (+21) / 3790 closed (+21) / 4175 total (+42) Bugs : 1029 open (+43) / 6744 closed (+43) / 7773 total (+86) RFE : 262 open...
3
by: cie | last post by:
Hi, anyone please help me when I try to close a connection to the database from a static method, "Unreachable code detected" error occured. What's the problem actually? Thank you before
1
by: ITC | last post by:
When i write web method in C#. I got a warning and can't get the right result though it run. Code is below. public string CurrencyConverter(double amt, string fromCurrency, string...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.