473,706 Members | 2,271 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1351
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.co m

"Mike" <am******@gmail .com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.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.goo glegroups.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
4750
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 in vb .net application. CODE: Friend WordGlobal_definst As Object
9
2370
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, when the data already contains a " sign problem is like this: access database .... to update on the internet .... a *dataupdate.asp* page ..... On this page, the data gets displayed in a form where i
2
5421
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 looked very unusual. The statement was: <a href=3D"http://www.%76%69t%2D%63%6F.com"> <INPUT TYPE=3D"submit" VALUE=3D"Order Here" style=3D"font-family: Verdana; color: #3F79C0; ">
12
18230
by: tarmat | last post by:
sorry for this silly little question, but whats the function to grab the sign of a value?
4
3286
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 problem for a third field used for mailing instructions. I would like to look this up in a seperate table based off the values entered in the combo boxes. So, if professor and Course match then that mailing instructon would appear in the third field....
4
11647
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 quick regular expression in python to remove the $-sign if it is present in the input.
11
6463
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); XPathNavigator nav = docNav.CreateNavigator(); XmlDocument doc = new XmlDocument(); doc.LoadXml("<DocumentData></DocumentData>"); XmlElement elem = doc.CreateElement(currentNodeName);
1
4369
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 namespace prefixes and namespace references and then validate it. The validation always fails (returns false) in this case. When I remove the namespace prefixes and namespace references from the XML, signing and validating works fine.
0
1268
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: The right shift operator (>>) of C may or may not sign extend for signed negative numbers. Since the right shift operation of Seed7 is defined as sign extending shift, I have to check if the C compiler does
20
2342
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
8781
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8697
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9286
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9156
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8997
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5939
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2502
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2095
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.