Your full service technology partner! 
-Collapse +Expand
Search C# Group:

-Collapse +Expand C# To/From
-Collapse +Expand C# Study Test
-Collapse +Expand C# Store

Prestwood eMagazine

September Edition
Subscribe now! It's Free!
Enter your email:

   ► KBProgrammingC#Tool Basics   Print This     
  From the February 2015 Issue of Prestwood eMag
C# Tool Basics:
C# Case Sensitivity (Yes)
Posted 12 years ago on 12/31/2008 and updated 10/24/2009
C# Code Snippet:
 A flashcard from our C# Flashcards Library
 A code snippet from our C# Code Snippets Page


Languages Focus: Case Sensitivity

Case sensitiviy in this case is referring to commands and variable names. For example, are "printf" and "PrintF" equivalent? Are fullname and FullName equivalent? When you create commands, operations, methods, or variables should you worry about case?

C# Case Sensitivity

In C# commands and variable names are case sensitive. The following does NOT:

messagebox.Show("hello");  //Does not compile!

The first time you type any other case for commands or variables, VS.Net will change it to the accepted or defined case. For example, if you type it is converted to MessageBox.Show. Once corrected, you can break it again by editing MessageBox to messagebox and the compiler will give you an error.

Syntax Example:

The following code works:


Wrong Cased Variables Give Compiler Error

If you declare a variable with one case and attempt to use it with another case, you'll get a compiler error.

For example:

String MyName;
myname = "Felicia";   //Compiler error.
MessageBox.Show("Hello " + MyName);

Using Same Named-Different Cased Variabes

You can have the same named variable with an alternate case. Although not the best idea, the following does work:

String MYNAME;
String MyName;
MYNAME = "Nathan";
MyName = "Felicia";
MessageBox.Show("Hello " + MYNAME); //Shows Nathan.
MessageBox.Show("Hello " + MyName); //Shows Felicia.


Share a thought or comment...
Write a Comment...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.

Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1293A1
Enter key:
Code Contributed By Mike Prestwood:

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Visit Profile

Linked Certification Question(s)

The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.


1 Beginner Level Question

Question #1: True or False?

In C# you can declare and use a variable spelled the same but with a different case as in the following:

Int16 InvoiceNumber;
InvoiceNumber = 1001;
MessageBox.Show("" + InvoiceNumber);
MessageBox.Show("" + INVOICENUMBER);
  • True
  • False

  •  KB Article #101336 Counter
    Since 12/31/2008
    Sales Website: Or visit our legacy sales site:

    ©1995-2020 Prestwood IT Solutions.   [Security & Privacy]