Search code examples
c#enumsflagswinmmenum-flags

How to make hex vals acceptable to the compiler?


I'm trying to use the code at http://www.pinvoke.net/default.aspx/coredll/playsound.html

It causes several err msgs, though, namely: "Unexpected character '×'" 26 times.

So, I tried changing the vals to verbatim strings, like so:

SND_SYNC = @"0×0000",

...but now I get "Cannot implicitly convert type 'string' to 'int'

I realize that I can convert those strings to ints, but is that really the way to do it? I'm afraid I might be able to get it to compile that way, but that it still won't work (or worse). What is the appropriate way to mark these hex vals as such, so that the compiler accepts them?

Here's the first bit of the code:

[DllImport("winmm.dll", SetLastError = true)] static extern bool PlaySound(string pszSound, UIntPtr hmod, uint fdwSound);

[Flags]
public enum SoundFlags
{
    SND_SYNC = 0×0000, // <- "unexpected char 'x'"

Solution

  • In my case, at least, I had to change all of the lowercase x's to uppercase X's to get it to work.