If the scenario is not realy a role based access. and what you want is two objects say
Object1 and Object2
where Object1 can access 3 methods of that class and
Object2 can access 2 methods of that class, then you may need to Do as follow.
Create two interfaces and a class as shown below.
interface IUser1
{
void Method1();
void Method2();
void Method3();
}
interface IUser2
{
void Method4();
void Method5();
}
class Users: IUser1,IUser2
{
public void Method1()
{
}
public void Method2()
{
}
public void Method3()
{
}
public void Method4()
{
}
public void Method5()
{
}
}
now create object for the class.
IUser1 userA = new Users();
userA.Method1();
userA.Method2();
userA.Method3();
IUser2 userB = new Users();
userB.Method4();
userB.Method5();
IUser1 userA = new Users();
userA.Method1();
userA.Method2();
userA.Method3();
IUser2 userB = userA;
userB.Method4();
userB.Method5();
now here userA can access only
Method1();
Method2();
Method3();
and userB can access only
Method4();
Method5();
now if you are trying to solve role based problems then return the corresponding Interface object which is appropriate for the role and your issue will be solved.
Hope this will help.