473,396 Members | 1,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using the # sign

Hello,
I have an enum that uses the # sign in a Constant and I'm getting
syntax errors. How do I excape this in my code.
enum Notes
{
A,
A#,
B,
C,
C#,
D,
D#,
E,
F,
F#,
G,
G#
}
Thanks
Mike

Feb 14 '06 #1
5 1337
Mike,

The compiler will not allow this, since the identifer is invalid. You
will need to use ASharp, CSharp, etc, etc. Personally, I think that this is
more readable.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mike" <am******@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Hello,
I have an enum that uses the # sign in a Constant and I'm getting
syntax errors. How do I excape this in my code.
enum Notes
{
A,
A#,
B,
C,
C#,
D,
D#,
E,
F,
F#,
G,
G#
}
Thanks
Mike

Feb 14 '06 #2
Enums must follow the same constraints that any variable or symbols follow.
If you cannot make a variable with that name then you cannot make an enum
value with that name.

"Mike" <am******@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Hello,
I have an enum that uses the # sign in a Constant and I'm getting
syntax errors. How do I excape this in my code.
enum Notes
{
A,
A#,
B,
C,
C#,
D,
D#,
E,
F,
F#,
G,
G#
}
Thanks
Mike

Feb 14 '06 #3
enum Notes
{
A,
Asharp,
B,
C,
Csharp,
D,
Dsharp,
E,
F,
Fsharp,
G,
Gsharp
}

Feb 14 '06 #4
Like everyone else said, you can't use '#' as an enum value ...but
since you're doing something related to music, you can also do this ...

enum Notes
{
A
Bb
B
C
Db
D
Eb
E
F
Gb
G
Ab
}

Granted, I hate seeing Gb instead of F# in music scores, it does get
the point across :)

Clint

Mike wrote:
Hello,
I have an enum that uses the # sign in a Constant and I'm getting
syntax errors. How do I excape this in my code.
enum Notes
{
A,
A#,
B,
C,
C#,
D,
D#,
E,
F,
F#,
G,
G#
}
Thanks
Mike


Feb 14 '06 #5
Thanks All
I think the ASharp syntax should work.And Clint, I feel the same way.
Mike

Feb 14 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: rwalker | last post by:
Error number 429 - COM object with CLSID {000209F0-0000-0000-C000-000000000046} is either not valid or not registered. Intermittent occurance of this error. Using Word.Global to run word macro...
9
by: cooldv | last post by:
i know how to replace the sign " when SUBMITTING a form in asp by this code: message = Replace(usermessage, "'", "''"). My problem is DISPLAYING data in an asp FORM, from an an access database,...
2
by: Don Clark | last post by:
Hello; Admittedly, I'm very new to HTML, and this is my first post to any newsgroup, so please go easy. I was looking at the html code for an email I received and noted an href statement that...
12
by: tarmat | last post by:
sorry for this silly little question, but whats the function to grab the sign of a value?
4
by: thx606 | last post by:
Hello, I'm having problems figuring this one out. I have 2 combo boxes. The first one the user selects a professor then the second one they select a course and that works fine. Here is my...
4
by: Kun | last post by:
i have an html/cgi input that takes in values to a mysql database, however, if i stick in $20 instead of 20, it crashes the program because of the extra $ sign. I was wondering if anyone has a...
11
by: ericms | last post by:
Can anybody show me how to insert a CDATA section using XPathNavigator ? I have tried the follwing with no luck: XmlDocument docNav = new XmlDocument(); docNav.LoadXml(xmlString);...
1
by: Peter Ravnholt | last post by:
Hello all, It seems that digitally signing XML documents using the SignedXml class has a bug - or at least a behavior I cannot explain. The problem occurs when I sign XML documents containing...
0
by: thomas.mertes | last post by:
Generally C is well suited as target language for compilers. I use C as target language for the Seed7 compiler. This works good. There are just some things where the behaviour of C is undefined: ...
20
by: Ravikiran | last post by:
Hi Friends, I wanted know about whatt is ment by zero optimization and sign optimization and its differences.... Thank you...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.