Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to make the C# compiler issue a warning when instance variable is hidden(shadowed)?

I am refactoring a little bit of code and I think I have created some instance variables that are being hidden(shadowed) in older methods. I want to see a warning wherever the hiding(shadowing) happens so I can check to make sure that it's actually what I want (and it's hardly ever what I want). Is there any easy way to do that?

like image 743
Chris Pfohl Avatar asked Nov 23 '10 18:11

Chris Pfohl


People also ask

Is there an alternative to C?

The best alternative is Java. It's not free, so if you're looking for a free alternative, you could try C++ or Rust. Other great apps like C (programming language) are Go (Programming Language), C#, Lua and Perl.

Is C hard to write?

Is C The Hardest Language? No, C is not the most difficult language. However, the programming language is relatively challenging to learn. If you are a beginner in programming, you can start by building a solid foundation in computer science before progressing to C.

Why is C easy?

C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.

Is C tough to learn?

C is more difficult to learn than JavaScript, but it's a valuable skill to have because most programming languages are actually implemented in C. This is because C is a “machine-level” language. So learning it will teach you how a computer works and will actually make learning new languages in the future easier.


2 Answers

If you run Code Analysis, that'll show up (as CA1500 from the Maintanability section).

like image 81
bdukes Avatar answered Sep 27 '22 20:09

bdukes


Have you looked into any productivity tools such as Resharper? http://www.jetbrains.com/resharper/

It will find that (and probably proactively warn you) with very little effort on your part.

like image 27
SRM Avatar answered Sep 27 '22 22:09

SRM