私が使用したいサンプルはThis SO articleです。C#IF文でこの例の "return"を使用するにはどうすればよいですか?
public static bool HasWritePermissionOnDir(string path)
{
var writeAllow = false;
var writeDeny = false;
var accessControlList = Directory.GetAccessControl(path);
if (accessControlList == null)
return false;
var accessRules = accessControlList.GetAccessRules(true, true, typeof(System.Security.Principal.SecurityIdentifier));
if (accessRules == null)
return false;
foreach (FileSystemAccessRule rule in accessRules)
{
if ((FileSystemRights.Write & rule.FileSystemRights) != FileSystemRights.Write) continue;
if (rule.AccessControlType == AccessControlType.Allow)
writeAllow = true;
else if (rule.AccessControlType == AccessControlType.Deny)
writeDeny = true;
}
return writeAllow && !writeDeny;
}
どのように私は、If文で "writeAllow & &返す!writeDeny" を使用することができますか?あるいは私はそれを行うこともできますか?申し訳ありませんが、これは愚かな質問ですが、私の限られた経験の中で私はそのようなリターンの外観を見ていない。
あなたは表現が続くキーワード 'return'を見ていませんか? 'return 1 + 2;'これはもっとよく知られていますか?それは同じことです。 –
以上である。 'true true && false;' –