Is there any way to access private memebers of an object
from another object?
Answer Posted / rajesh
In C++ we can access private members of one class by the
object of another class,befor that we have to
make "friend"(keyword) the respective member of the first
class to the second class
for ex:
class A
{
private void display();
};
inherits: class B
{
friend void display();
};
Now we can acess the 'display' function using classB
object.We can only make friend to the immediate inherited
class and not to all classes under inheritance.
and in C# we have to create a property as first answer
Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
What is array c#?
Why do we need singleton pattern in c#?
How do you create user defined data types in c#?
Which framework is best for desktop application?
Why do we need to override in c#?
What is definition in c#?
Explain the difference between the system.array.copyto() and system.array.clone()?
When should you use generics?
What is the difference between xml documentation tag?
What are extender provider components?
Why References are stored on heap and variables on stack?
if a base class has a number of overloaded constructors, and an inheriting class has a number of overloaded constructors; can you enforce a call from an inherited constructor to a specific base constructor?
What is the difference between Java and .NET garbage collectors?
How do I edit a dll file?
What is the meaning of int parse in c#?