문제

I have partial class as follows

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

and two static properties. When I set the static property, I got error in static method.

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();
        }
    }
}
도움이 되었습니까?

해결책

The problem is not the partial keyword. Rather, you didn't have access modifiers on your class' properties. This means that they're private by default. To solve this, simply add public to your property declarations.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top