asked on
namespace ExampleForProperty
{
class Program
{
private string pvtStr;
public string GetPvtStr(ICallerAccess iCallerAccess)
{
if (iCallerAccess.AllowAccess)
{
return pvtStr;
}
else
{
throw new ApplicationException("Access Denied");
}
}
public void SetPvtStr(string value, ICallerAccess iCallerAccess)
{
if (iCallerAccess.AllowAccess)
{
pvtStr = value;
}
else
{
throw new ApplicationException("Access Denied");
}
}
static void Main(string[] args)
{
A ob = new A();
B ob1 = new B();
ob.calfrmA();
ob1.calfrmB();
}
}
class A : ICallerAccess
{
public void calfrmA()
{
Program obj = new Program();
obj.SetPvtStr("12345", this);
}
public bool AllowAccess
{
get
{
return true;
}
}
}
class B : ICallerAccess
{
public void calfrmB()
{
Program obj1 = new Program();
obj1.SetPvtStr("12345", this);
}
public bool AllowAccess
{
get
{
return false;
}
}
}
public interface ICallerAccess
{
bool AllowAccess { get; }
}
}
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.
TRUSTED BY