We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module Module1 <Flags()> Public Enum FillType All = &H1 Latest = &H2 Clean = &H4 Recursive = &H8 Append = &H10 CleanAndLatest = Clean Or Latest End Enum Sub Main() Dim test1 = Test(FillType.All) Console.WriteLine("FillType.All -> " & test1) Dim test2 = Test(FillType.Latest) Console.WriteLine("FillType.Latest -> " & test2) Dim test3 = Test(FillType.Recursive) Console.WriteLine("FillType.Recursive -> " & test3) Dim test4 = Test(FillType.Append) Console.WriteLine("FillType.Append -> " & test4) Dim test5 = Test(FillType.CleanAndLatest) Console.WriteLine("FillType.CleanAndLatest -> " & test5) Dim test6 = Test(FillType.All Or FillType.Recursive) Console.WriteLine("FillType.All Or FillType.Recursive -> " & test6) Console.ReadLine() End Sub Function Test(options As FillType) As Object Dim opts As Object If (options And Not FillType.Recursive) = 0 Then opts = FillType.All Else opts = options And Not FillType.Recursive End If Return opts End Function End Module
using System; using Microsoft.VisualBasic.CompilerServices; namespace ConsoleApp4 { static class Module1 { [Flags()] public enum FillType { All = 0x1, Latest = 0x2, Clean = 0x4, Recursive = 0x8, Append = 0x10, CleanAndLatest = Clean | Latest } public static void Main() { var test1 = Test(FillType.All); Console.WriteLine(Operators.ConcatenateObject("FillType.All -> ", test1)); var test2 = Test(FillType.Latest); Console.WriteLine(Operators.ConcatenateObject("FillType.Latest -> ", test2)); var test3 = Test(FillType.Recursive); Console.WriteLine(Operators.ConcatenateObject("FillType.Recursive -> ", test3)); var test4 = Test(FillType.Append); Console.WriteLine(Operators.ConcatenateObject("FillType.Append -> ", test4)); var test5 = Test(FillType.CleanAndLatest); Console.WriteLine(Operators.ConcatenateObject("FillType.CleanAndLatest -> ", test5)); var test6 = Test(FillType.All | FillType.Recursive); Console.WriteLine(Operators.ConcatenateObject("FillType.All Or FillType.Recursive -> ", test6)); Console.ReadLine(); } public static object Test(FillType options) { object opts; if ((int)(options & !FillType.Recursive) == 0) { opts = FillType.All; } else { opts = options & !FillType.Recursive; } return opts; } } }
using System; using Microsoft.VisualBasic.CompilerServices; namespace ConsoleApp4 { static class Module1 { [Flags()] public enum FillType { All = 0x1, Latest = 0x2, Clean = 0x4, Recursive = 0x8, Append = 0x10, CleanAndLatest = Clean | Latest } public static void Main() { var test1 = Test(FillType.All); Console.WriteLine(Operators.ConcatenateObject("FillType.All -> ", test1)); var test2 = Test(FillType.Latest); Console.WriteLine(Operators.ConcatenateObject("FillType.Latest -> ", test2)); var test3 = Test(FillType.Recursive); Console.WriteLine(Operators.ConcatenateObject("FillType.Recursive -> ", test3)); var test4 = Test(FillType.Append); Console.WriteLine(Operators.ConcatenateObject("FillType.Append -> ", test4)); var test5 = Test(FillType.CleanAndLatest); Console.WriteLine(Operators.ConcatenateObject("FillType.CleanAndLatest -> ", test5)); var test6 = Test(FillType.All | FillType.Recursive); Console.WriteLine(Operators.ConcatenateObject("FillType.All Or FillType.Recursive -> ", test6)); Console.ReadLine(); } public static object Test(FillType options) { object opts; if ((int)(options & ~FillType.Recursive) == 0) { opts = FillType.All; } else { opts = options & ~FillType.Recursive; } return opts; } } }
Dropping a bit with bitwise operator in VB.NET is done with a combination of AND and NOT :
https://stackoverflow.com/a/38201868/444469
whereas in C# it's done with & and the complement operator ~ :
https://stackoverflow.com/a/4778181/444469
The text was updated successfully, but these errors were encountered:
Thanks for the full example and explanation. Should be a straightforward adjustment to convert Not into ~ for numeric types
Sorry, something went wrong.
c571542
I believe this is fixed in e596227
No branches or pull requests
Input code
Erroneous output
Expected output
Details
Dropping a bit with bitwise operator in VB.NET is done with a combination of AND and NOT :
https://stackoverflow.com/a/38201868/444469
whereas in C# it's done with & and the complement operator ~ :
https://stackoverflow.com/a/4778181/444469
The text was updated successfully, but these errors were encountered: