combining FontStyle

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I know this is probably an easy question. But in VB.Net when you instantiate
a fontstyle object, the parameter for fontstyle, if you wanted it to be Bold
and Italic, you would enter "FontStyle.Bold + FontStyle.Italics". But in C#,
it does not like that syntax. What is the proper syntax in C#?
 
FontStyle.Bold | FontStyle.Italics

| is the bitwise or operator, which is what is wanted when combining [Flags]
enums.

In fact *strictly* speaking in VB.Net you should be using "FontStyle.Bold Or
FontStyle.Italics", otherwise you risk getting screwy numbers if one enum
value automatically includes another.

Marc
 
Back
Top