In the below example ...there is a public property for a private member in class program
both the class A and B hve obj of class program
If the call to set or get the value of private string pvtstr from A should be allowed but if call from class B should not be allowed
In simple how do i find from which class the cal is comming from ...to set or get the value of a private memeber using public property
namespace ExampleForProperty
{
class Program
{
private string pvtStr;
public string _pvtstr
{
get
{
return pvtStr;
}
set
{
pvtStr = value;
}
}
static void Main(string[] args)
{
A ob = new A();
B ob1 = new B();
ob.calfrmA();
ob1.calfrmB();
}
}
class A
{
public void calfrmA()
{
Program obj = new Program();
}
}
class B
{
public void calfrmB()
{
Program obj1 = new Program();
}
}
}
Our community of experts have been thoroughly vetted for their expertise and industry experience.