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
Name some string escape sequences in c#.
What is var c#?
who is a protected class-level variable available to?
Why objects are stored in heap in c#?
Which types of inheritances does c# support?
Is it possible to inline assembly or il in c# code?
Explain hash table in c# ?
What are reflections in c#?
How can encapsulation be achieved?
Can a static class have a constructor c#?
What is the difference between a variable and a literal?
What is Wrapper class in dot net?
What's the c# syntax to catch any possible exception?
What is ienumerable and iqueryable?
What is use of hashtable in c#?