Is there any way to access private memebers of an object
from another object?
Answer Posted / porchelvi.a
We can achieve this by using Reflection.
By using Reflection we can access some information about
object at runtime.even we can invoke private method of an
object by using Reflection.
Example :
Class Student
{
private int RollNo;
public string Name;
}
class MainClass
{
Type type=typeof(Student); //to get type information
MemberInfo[] mem=type.getMembers();
foreach(Memberinfo m in mem)
//we can get every member here
}
Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
Why do I get a syntax error when trying to declare a variable called checked?
what are the differences between a class and structure
What does dbml mean in texting?
What is private protected in c#?
Is null == null c#?
What is the use of table aliases?
What is type safe in c#?
What is difference between private and protected?
Define thread? Explain about multithreading?
What is difference between singleton and static class in c#?
Is Multiple-inheritance supported by c#?
What is yield break in c#?
Can abstract class be sealed in c#?
Why do we need constructor?
Can we have multiple threads in one app domain?