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.
使用~
运算符翻转位。
按位not
运算符是~
。
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.