We help IT Professionals succeed at work.
Get Started

How do i stop the access for some classes

Last Modified: 2012-05-11
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
                return pvtStr;
                pvtStr = value;

        static void Main(string[] args)
            A ob = new A();
            B ob1 = new B();

    class A
        public void calfrmA()
            Program obj = new Program();

    class B
        public void calfrmB()
            Program obj1 = new Program();

Watch Question
This problem has been solved!
Unlock 1 Answer and 17 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE