Max
Max

Reputation: 13

Combining multiple flags of an enum?

I've been trying to use multiple flags for the SpeechLibs Talk() function. This is what I am trying to do:

V.Speak ("Text", SpeechVoiceSpeakFlags.SVSFlagsAsync + SpeechVoiceSpeakFlags.SVSFIsXML);

However, it gives me following error:

Error 1 Operator '+' cannot be applied to operands of type 'SpeechLib.SpeechVoiceSpeakFlags' and 'SpeechLib.SpeechVoiceSpeakFlags' c:\users\max\documents\visual studio 2013\projects\switch\switch\default_tts_screen.cs 62 51 Switch

The documentation though clearly states that this should be possible:

Example
The following code snippet demonstrates the Speak method with several   commonly used flag settings.
[...]
V.Speak "text with XML", SVSFIsXML + SVSFlagsAsync
[...]

Please note that I am using C#, this however shouldn't change anything. Right?.. Please help me with this problem as it's already been smashing my head into my table since hours now. I haven't found a solution to this online.

Upvotes: 1

Views: 4244

Answers (1)

spender
spender

Reputation: 120518

You combine enum flags with a bitwise OR operator as follows:

V.Speak ("Text", SpeechVoiceSpeakFlags.SVSFlagsAsync | SpeechVoiceSpeakFlags.SVSFIsXML);

Upvotes: 4

Related Questions