Mihir Solanki

mihirsolanki.com

<November 2008>
SuMoTuWeThFrSa
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456


Navigation

Links

Subscriptions

Post Categories



The FontStyle Enumeration and Bitwise Operations

The FontStyle enumeration has a Flags attributes that allows bitwise operations on FontStyle values. For example, look at the following statement:

lblSampleText.Font.Style | FontStyle.Underline

Here the | operator will turn on all the bits representing the Underline style, returning a FontStyle value  that adds Underline to the existing font Style of lblSampleText.

The following expression involves a bitwise exclusive OR (XOR) operation:

lblSampleText.Font.Style ^ FontStyle.Underline

This expression returns a FontStyle value that toggles the Underline font style of the label. If the label was already underlined, the new value has the underline removed; if the label was not underlined already, the Underline bits are set in the new value.

The following expression involving a bitwise AND does not have any effect because using AND with 1 always returns the original value:

lblSampleText.Font.Style & FontStyle.Underline

PS : Leave your feedbacks/comments here

posted on Monday, March 28, 2005 5:26 PM by mihirsolanki





Powered by Dot Net Junkies, by Telligent Systems