Can't get values from Dictionary Property in C# -


i have following code class called role

public static class role {     private static dictionary<string, list<permissions>> _userrole;     private static list<permissions> _userpermission;      public static dictionary<string, list<permissions>> userroleinfo     {         { return _userrole; }     }      public role()     {         _userrole = new dictionary<string, list<permissions>>();          _userpermission = new list<permissions>();     }} 

in class i'm trying value of matching key userroleinfo property

list<permissions> value = role.userroleinfo(authenticatedusername) 

but following error

error   7   non-invocable member 'user.role.userroleinfo' cannot used method. 

any idea how around or mistake, because using

if(role.userroleinfo.containskey(authenticatedusername)) 

works fine

  1. the right syntax getting dictionary value in c# is

    role.userroleinfo[authenticatedusername] 
  2. initializing static member instance constructor bad idea. want constructor static well. (or make fields , property non-static - whichever makes more sense usage)


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -