I have created a static class which contains some static values list. Now I want to access these values out side from this class. I need to know how can I do this? The code example is provided below:
public class RoleList
{
static public List<RoleDetials> Roles()
{
List<RoleDetials> roleDetaildsList = new List<RoleDetials>();
roleDetaildsList.Add(new RoleDetials
{
Id = 1,
Name = "admin"
});
roleDetaildsList.Add(new RoleDetials
{
Id = 2,
Name = "sadmin"
});
roleDetaildsList.Add(new RoleDetials
{
Id = 3,
Name = "badmin"
});
return roleDetaildsList;
}
}
public class RoleDetials
{
public int Id { get; set; }
public string Name { get; set; }
}
I already tried to like below but this way not works as per C# syntax.
var allRoles = RoleList.ToList();
Roles()? For exampleRoleList.Roles()