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
the right syntax getting dictionary value in c# is
role.userroleinfo[authenticatedusername]
initializing static member instance constructor bad idea. want constructor
static
well. (or make fields , property non-static - whichever makes more sense usage)
Comments
Post a Comment