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
Are c# strings null terminated?
What is desktop example?
Give some examples of commonly used i/o classes?
What is interface inheritance in c#?
What is a static field?
What is a generic c#?
What is extension method in c# and how to use them?
Can you see a loop recorder?
What is poco c#?
What is Global Assembly Cache (GAC) and what is the purpose of it? (How to make an assembly to public? Steps) How more than one version of an assembly can keep in same place?
What is the C# syntax to catch any possible exception?
What is the use of console application in c#?
Explain briefly the difference between value type and reference type?
What is serialization in dot net?
Explain anonymous type in c#?