簡體   English   中英

由於其保護級別而無法訪問

[英]is inaccessible due to its protection level

我有以下部分課程

public partial class ThisAddIn
{
    static string MD5Hash { get; set; }
    static string SHA1Hash { get; set; }
}

和兩個靜態屬性。 設置靜態屬性時,在靜態方法中出現錯誤。

public static void ComputeSHA1Hash(object filePath)
{
    using (var stream = new FileStream((string)filePath, FileMode.Open, FileAccess.Read))
    {
        using (var sha1gen = new SHA1CryptoServiceProvider())
        {
            sha1gen.ComputeHash(stream);
            ThisAddIn.SHA1Hash = BitConverter.ToString(sha1gen.Hash).Replace("-", "").ToLower();
        }
    }
}

問題不在於partial關鍵字。 相反,您在類的屬性上沒有訪問修飾符。 這意味着它們默認是private的。 要解決此問題,只需將public添加到您的屬性聲明中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM