troubleshooting Question

How do i stop the access for some classes

Avatar of Arun_Ganwar
Arun_Ganwar asked on
Office ProductivityC#.NET Programming
17 Comments1 Solution391 ViewsLast Modified:
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();

        }
    }
}
ASKER CERTIFIED SOLUTION
saragani

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 17 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 17 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros