VS 2005 - Case Sensitivity?

  • Thread starter Thread starter John Murray
  • Start date Start date
J

John Murray

Not sure that I understand your question .... C# is, by it's nature case
sensitive .... so that is not a configurable option ....
 
Is there any options in VS 2005 to better handle case issues in C#
(Similar to VB.Net)?

You would not want to do that since writing code of this kind:

MyType myType = new MyType();

Is a widespread (and valid, language-wise) practice... Or did I
misunderstand your question?
 
Is there any options in VS 2005 to better handle case issues in C# (Similar
to VB.Net)?
 
It sounds like what you are asking is "Is there any way I can make the C#
language be case-insensitive like Visual Basic.NET?"

The answer is, of course, no, you cannot. C# is case - sensitive,, as is
C++, Javascript, and the Unix filesystem. That's a good thing!
Peter
 
Yes, as you start to type, intellisense suggests auto-completions for what
you are typing, regardless of the casing. If you select an element off the
list, it is pasted with the correct casing.

Also, the identifier is colored in black if it could not be found. It is
greenish-colored if it could be found, so you can see at a glance if the
class/struct/etc... can be seen by VS.
 
2 words.. not trying to be mean but it will probably come across that way

"Program better!"

Not wanting to care about case is IMHO crazy.. I hate looking through code
that looks like this:

int MyID;
myid=10;
if(myID > 100)
mYId = 1;
else
myiD++;

Now that is an extreme example but it kind of shows what I mean. If you
call something MyID then call it that.

If you really dont want to worry about case then just use all lower
letters.. At least all references to the variables would be consistant.

int myid;
myid=10;
if(myid > 100)
myid = 1;
else
myid++;


Consistancy is rule #1 in my book. No matter what you are talking about.
 
Ok, last time I was using VS2003 with C# the editor seemed to get confused
if I was using different cases (or a typo).

In VB.Net, the editor can always find the right object (since it doesn't
care about case).

Has the Editor improved any to let me better use auto-complete
(intellisense) on mixed case objects ...or at least help me identify a typo?
 
Awesome!

It felt like my left foot was cut off in VS2003. I refused to use C#
because the editor was so poorly integrated (compared to VB.NET)..... sounds
like I can finally start looking at C# again.
 
Awesome!

It felt like my left foot was cut off in VS2003. I refused to use C#
because the editor was so poorly integrated (compared to VB.NET)..... sounds
like I can finally start looking at C# again.

Actually, that behaviour was in VS 2003 for C# as well. Just hit
Ctrl-Space to complete something regardless of case.
 
VS2003 Intellisense also does case-insensitive identifier completion.
Problems crop up for me only when I use two identifiers that differ
only by case, for example:

public class A
{
private string abcd;
...
public string Abcd { get { return this.abcd; } }
}

within class A, typing "this.abcd" would choose either the field or the
property, depending upon which was more often used. I solved the
problem simply by changing conventions for naming identifiers.
 
int MyID;
myid=10;
if(myID > 100)
mYId = 1;
else
myiD++;
The thing is, if this code were written in the case-insensitive VB.NET, the
background compiler would change all variations of MyID to match the
definition. You'd never see code like that.

What *I* hate is seeing two variables names that differ only by the case of
a single letter. To me, its more likely to that someone reading this type
of code would be mistaken about which variable they were actually looking
at.
"Program better!"
The subjective opinion on case-sensitivity has nothing to do with
programming "better". There are plenty of programmers on either side of
this issue.

- Mitchell S. Honnert
 
I just think of programming as more of an art form.. Creating something
usefull that also looks pleasing to the eyes.

In the end it is always personal preference on what you do in your own code.
I just know that when I look at code I like to see things that are easy to
follow and understand.

Having multiple variables that are different only by the case is a big no-no
in my book as well. The only time this could be considered valid is if it is
a parameter of a method.

Ex. would be something like this:

int UserNumber; // member variable in a class

String SetUserNumber(int usernumber)
{
UserNumber = usernumber;
}

Just my 2 cents I guess..
 
In the end it is always personal preference on what you do in your own
True enough.
I just know that when I look at code I like to see things that are easy to
follow and understand.
So...readability is in the eye of the beholder? ;-) Of course, any
programmer is going to agree that easy-to-follow and understandable code is
preferable, but objectively what promotes this? You can say that one
shouldn't name variables in such a way that case-sensitivity would cause
confusion, but in my opinion case-insensitivity naturally promotes
easy-to-understand code. There are a near-infinite number of variable names
you can use; why risk confusion by, for example, having the private member
variable and the public property name be the same except for case?
String SetUserNumber(int usernumber)
I think the MS naming standard says to use camelCase for parameter names.
userNumber? :-)

- Mitchell S. Honnert
 
Is there any plug-in or macro or option for the a case crippled programmer?

It would be nice to see a warning if two variables show up with differing
case. This is my biggest timewaster when using C#.

I respect all the folks that really find the below code an art form (I might
think your crazy, but I respect your opinions), but for me its just
silliness that VS cant help me keep this from happening.
 
I believe that FxCop warns about things like this.

You can download FxCop for free from Microsoft, if you don't have it
already. I also heard rumours that it was built into VS2005, although I
don't know for sure.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top