VB.Net中是否有C#的管道运算符(|)的等效项?
我在这里有一些代码How to grant full permission to a file created by my application for ALL users?
它在C#中,我想将其转换为VB.Net。我到目前为止(VS说有错误:| InheritanceFlags.ContainerInherit):
Sub ZugriffsrechteEinstellen()
Dim dInfo As New DirectoryInfo(strPfadSpracheINI)
Dim dSecurity As New DirectorySecurity
dSecurity = dInfo.GetAccessControl()
dSecurity.AddAccessRule(New FileSystemAccessRule(New SecurityIdentifier(WellKnownSidType.WorldSid, Nothing), FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.NoPropagateInherit, AccessControlType.Allow))
dInfo.SetAccessControl(dSecurity)
End Sub
答案 0 :(得分:7)
等效为Or
。
InheritanceFlags.ObjectInherit Or InheritanceFlags.ContainerInherit
它将在操作数之间执行按位“或”运算。
例如,如果您具有以下枚举
C#:
enum Values
{
None = 0,
Odd = 1,
Even = 2,
All = 3
}
VB:
Enum Values
None = 0
Odd = 1
Even = 2
All = 3
End Enum
Values.Odd | Values.Even
(Values.Odd Or Values.Even
)的结果为Values.All
。这是因为Odd = 1
是二进制形式的01
,而Even = 2
是10
,并且01 or 10
等于11
,即3 (All)
。 / p>