Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Warning 1 The field 'MCS_SPS_School.Fees.DiscountAmt.rtvalue' is assigned but its value is never used G:\Jagadeeswaran\Nov 17\MCS-SPS School\MCS-SPS School\Fees\DiscountAmt.cs

Warning 2 The field 'MCS_SPS_School.Fees.DiscountAmt.dt' is never used G:\Jagadeeswaran\Nov 17\MCS-SPS School\MCS-SPS School\Fees\DiscountAmt.cs

This type of warning is still in my project. But the project runs safely.

Now what I do for this warnings, to fix or Ignore?

Is any dangerous if ignore that, performance wise or other?

share|improve this question

4 Answers 4

up vote 11 down vote accepted

It's not directly a safety problem, but it might be an indirect one. That's why it's a warning. The compiler is telling you that you've declared something but you aren't actually doing anything with it, which most likely means that your code is incomplete: you started building something and didn't finish it. This could cause bugs further down the line.

The best way to fix this warning is to either finish writing whatever was supposed to use this value, or delete it.

share|improve this answer
    
That's why it's a warning. --- Thanks. –  Sagotharan Dec 26 '11 at 14:40

The warning means exactly that - you have declared fields in your classes that you never use.

Warning 1 means that your DiscountAmt.cs file has fields named rtvalue and dt that are declared but not referenced anywhere.

These fields take some space for each instance of the class, even though they are never used - best practice is to delete such fields.


There is another issue to do with warnings - if you don't fix these, you end up with many warnings. Some of these warnings are important, but you will never notice them because you have many other warnings that these get lost in the noise. A good practice is to have 0 warnings and 0 errors.

share|improve this answer
    
A good practice is to have 0 warnings and 0 errors. -- Very Very Thanks –  Sagotharan Dec 26 '11 at 14:39
    
But not everything that is causing warning is bad. But then its good practice to explicitely supress this occurance of warning (and explain why in comment) –  user470365 Dec 26 '11 at 18:28
    
@user470365 - true. But you did ask about this specific warning, not all warnings. –  Oded Dec 26 '11 at 18:48

Always fix warnings and hints. They point to issues that can pose problems later on.

Even if this warning seems unimportant, when you start ignoring "unimportant" hints and warnings, you will soon be drowned in them and then you won't spot the ones that are in fact very important and do cause bugs if unaddressed.

Any development team serious about code quality will have a zero hints and warnings policy in place. Our build server will continue a build when some projects produce hints and warnings, but our QA department will be all over us if we allow these to propagate from "work" branches into the main development branch. And issues in work branches won't be "resolved" (accepted for integration into the main development branch) by them until all hints and warnings are gone and all unit tests succeed.

share|improve this answer
    
Thanks for ur best information. –  Sagotharan Dec 26 '11 at 14:41

if you are delaying the fix for this item until later stage of the project you can turn of the warning message by using the #pragma warning disable see link: Pragma warning

otherwise remove the item if you are not using it until it is needed :)

share|improve this answer
    
now only i know pragma warning is there in .net. Thanks –  Sagotharan Dec 26 '11 at 14:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.