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
Can you put two constructor with the same structure in a class?
Why dataset is used in c#?
What is razor view in c#?
What is a function c#?
How can I access the registry from c# code?
Explain the difference between object type and dynamic type variables in c#?
What is the difference between select and selectmany?
What is connection pooling in ado.net?
How do I declare a pure virtual function in c#?
Are arraylist faster or arrays?
What is .edmx file?
Can abstract class have parameterized constructor?
Write a C# program to find the Factorial of n
What is serialization in dot net?
how to stored and retrive video in Sql server using asp.net c#......?