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 we need abstract class?
Can we create extension method for interface?
What is the use of ispostback in c#?
What is the difference between static and private constructor?
Hi to all..I have to create an intranet application on C#.NET windows Application so please please let can you people help me as iam new in .NET and if u have any samples or website address from where i can get sample please let know.
What is threading in c# with example?
What is the difference between protected and private?
Why to use “finally” block in c#?
What is binary search tree in data structure?
Why delegates are type safe?
Give examples for value types?
How do you escape c#?
What is the purpose of abstract class in c#?
What's the difference between abstraction and encapsulation?
How many root nodes are there in an xml document?