p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 3.5 Basics (http://p2p.wrox.com/forumdisplay.php?f=351)
-   -   IDs can't start with a number (http://p2p.wrox.com/showthread.php?t=77745)

acr.repair January 12th, 2010 12:56 AM

IDs can't start with a number
 
I have noticed that I cannot use a number in the beginning of an ID even though the book I am reading (Beginning ASP.NET 3.5) gives some example IDs in that format. Why is that?

om_prakash January 12th, 2010 02:47 AM

To use variables in your C# programs, you must know how to create variable names. In C#, variable names must adhere to the following rules:
  1. The name can contain letters, digits, and the underscore character (_).
  2. The first character of the name must be a letter. The underscore is also a legal first character, but its use is not recommended at the beginning of a name. An underscore is often used with special commands, and it's sometimes hard to read.
  3. Case matters (that is, upper- and lowercase letters). C# is case-sensitive; thus, the names count and Count refer to two different variables.
  4. C# keywords can't be used as variable names. Recall that a keyword is a word that is part of the C# language. (A complete list of the C# keywords can be found in Appendix B, "C# Keywords.")
Please check the following link on variables:
http://www.codeguru.com/csharp/sampl...le.php/c11387/

Imar January 12th, 2010 05:12 AM

Hi acr.repair,

Take a look at the errata for the book:

http://www.wrox.com/WileyCDA/WroxTit...Cd-ERRATA.html

You probably read lstFavoriteLanguage as firstFavoriteLanguage but is in fact listFavoriteLanguage. In other words, the first charcter is an lower case l as in List, not a 1 as in one or first.

Cheers,

Imar

acr.repair January 12th, 2010 02:18 PM

another example
 
You are probably correct about that one, however, in Beginning ASP.NET 3.5, what about chapter 5 page 158 where it ants me to use the ID
"1stOperator". Am I reading that one correctly?

Imar January 12th, 2010 03:53 PM

Hi there,

The book uses lst (with an l as in list) exclusively. I know for sure, as I wrote it ;-)

However, because of the font used for the text, it may *appear* as if it's written with a 1.

In my upcoming .NET 4 version of this book, I am no longer using this prefix to avoid this confusion, but use FavoriteLanguageList instead.

Cheers,

Imar


All times are GMT -4. The time now is 02:18 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.