If a method is marked as protected internal who can access it?

 Posted by Rajni.Shekhar on 3/19/2012 | Category: C# Interview questions | Views: 4994 | Points: 40
Answer:

Classes within the same assembly, and classes derived from the declaring class.

Example:

public class BaseEx

{
protected internal int xyz=10;
}
public class Derived : BaseEx
{
public string RetrunData()
{
return xyz.ToString();
}
}
public class MainClass{
Derived obj = new Derived();
Console.WriteLine("data:{0}",obj.RetrunData());
}


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response