Frage

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();
        }
    }
}
War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top