简体   繁体   中英

when used Dictionary How can I get the value if it non nullable value type

when used Dictionary

How can I get the value if it non nullable value type this code

            Dictionary<string, object> DictionaryValues = new Dictionary<string, object>();
            RSAParameters publicKey = Storage.Read(_Path + @"\" + "Key.Public");
            DictionaryValues["publicKey"] = publicKey;


            RSAParameters publicKey2 = new RSAParameters();
            if (DictionaryValues.TryGetValue("publicKey", out object obj))
            {
                publicKey2 = obj as RSAParameters;
                
            }

I'm getting an error the as operator must be used with a reference type or nullable type RSAParameters is anon nullable

How can I get the value publicKey from inside the dictionary Please help and thank you everyone

在此处输入图片说明

//publicKey2 = obj as RSAParameters;
  publicKey2 = (RSAParameters)obj;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM