Not all code paths return a value
-
Just to add the above:
Member 4081808 wrote:
return true; break;
Won't compile either: unreachable code - the "break" will never be executed as the method returns before it.
Did you know: That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
-
Just to add the above:
Member 4081808 wrote:
return true; break;
Won't compile either: unreachable code - the "break" will never be executed as the method returns before it.
Did you know: That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
-
lol thats wrong -> compile would succeed.. but bring up a warining as you described :D xyz :)
You mean you don't have "treat all warnings as errors" enabled? :omg: :laugh:
Did you know: That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
-
You mean you don't have "treat all warnings as errors" enabled? :omg: :laugh:
Did you know: That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
:thumbsup:
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use < PRE > tags for code snippets, it preserves indentation, and improves readability.
-
You mean you don't have "treat all warnings as errors" enabled? :omg: :laugh:
Did you know: That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
No. I develop in WPF where warnings are deferred until runtime.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
No. I develop in WPF where warnings are deferred until runtime.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
Have you tried adding
<option strict="on">
? :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use < PRE > tags for code snippets, it preserves indentation, and improves readability.
-
That's why I suggested a manual trace - but do people get taught how to that these days? :)
Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis The only valid measurement of code quality: WTFs/minute.
riced wrote:
but do people get taught how to that these days?
Well the course I did tried to. Of course they went to the other extreme and got us to design the application fully on paper and then set up test and run through manually and document the results, only once we had proved that the design worked as expected could we actually program it. I suppose it's good practice for simple programs (which was the case), to grasp the concept. But for most things it's usually quicker to design a more rough idea of what should be happening, code it and then debug the little problems. So in short, yes people do get taught that these days.
My current favourite quote is: Punch them in the face, see what happens!
-SK Genius
-
riced wrote:
but do people get taught how to that these days?
Well the course I did tried to. Of course they went to the other extreme and got us to design the application fully on paper and then set up test and run through manually and document the results, only once we had proved that the design worked as expected could we actually program it. I suppose it's good practice for simple programs (which was the case), to grasp the concept. But for most things it's usually quicker to design a more rough idea of what should be happening, code it and then debug the little problems. So in short, yes people do get taught that these days.
My current favourite quote is: Punch them in the face, see what happens!
-SK Genius
SK Genius wrote:
it's usually quicker to design a more rough idea of what should be happening, code it and then debug the little problems
Isn't this the essence of Test Driven Development?
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
public Boolean valid()
{
for (int i=0; i < cmbSampleName.Items.Count; i++)
{if (txtSampleName.Text == cmbSampleName.Items\[i\].ToString()) { return true; break; } else { return false; } } }
i want to check weather the current text in textbox is present in combobox or not plz help
I have been thinking about how it would make sense to write code like this. After all, you wouldn't have written it like this if you had no reason to do so. I think I figured it out - did you think that
return value;
only sets the value that will be returned, instead of immediately* returning that value? It all makes sense then - as long as they are not equal, you would keep the return value onfalse
; and when they are equal you'd set the return value totrue
and exit the method. The problem with that is, of course, thatreturn
doesn't "set the value that will be returned", it immediately* exits the method (and it also returns the specified value, of course) *: except in the presence oftry
/finally
-
public Boolean valid()
{
for (int i=0; i < cmbSampleName.Items.Count; i++)
{if (txtSampleName.Text == cmbSampleName.Items\[i\].ToString()) { return true; break; } else { return false; } } }
i want to check weather the current text in textbox is present in combobox or not plz help