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
What is for loop in c#?
What is lazy class in c#?
Why data types are important?
State two different types of access modifiers.
Can firstordefault return null?
What is parallel programming in c#?
What is a method c#?
Explain streamreader/streamwriter class?
Is versioning applicable to private assemblies?
Which of the following API is used to hide a window?
What is final keyword in c#?
Why is c# better than java?
Does c# support properties of array types?
what are pointer types in c#
What is the difference between dataset and datatable in c#?