Is there anyway I can get my private property of a class from another class? Here what I have tried.
class Program
{
static void Main(string[] args)
{
Sample aSample = new Sample();
//Is there anyway to access that Name private property here?
}
}
class Sample
{
private string Name { get; set; }
}
Pravesh Singh
16-Dec-2013Here I have tried with Reflection namespace and PropertyInfo class.
Please try it if you want property name with it's value. But in this case your property should be public. It shows all property names and their values.