2

I'm converting vb code to c#

There is enum from telerik library:

namespace Telerik.Windows.Controls
{
    // Summary:
    //     Provides flags for enumerating the ViewModes supported by Telerik.Windows.Controls.RadScheduler.
    [Flags]
    public enum AvailableViewModes
    {
        // Summary:
        //     Enables Day view.
        Day = 1,
        //
        // Summary:
        //     Enables Week view.
        Week = 2,
        //
        // Summary:
        //     Enables Month view.
        Month = 4,
        //
        // Summary:
        //     Enables Timeline view.
        Timeline = 8,
        //
        // Summary:
        //     Enables All views.
        All = 15,
    }
}

and code in vb is

cal.AvailableViewModes = cal.AvailableViewModes And Not AvailableViewModes.All

Converter returns me

cal.AvailableViewModes = cal.AvailableViewModes & !AvailableViewModes.All

and it's not correct because cannot applu operator ! to opperand of this enum.

2

3 Answers 3

7

Use the ~ operator to flip the bits.

Sign up to request clarification or add additional context in comments.

Comments

4

The bitwise not operator is ~.

Comments

3

Try the following instead

cal.AvailableViewModes = cal.AvailableViewModes & (~AvailableViewModes.All)

The converter is having a problem here because Not in VB.Net has two purposes: Boolean and bitwise. Which version is used depends on the type of the expression being targeted. Since Not is being used on a numeric value in the VB.Net code it's actually using the bitwise version. In C# the ~ operator is the equivalent.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.