Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is a namespace server?

926


What is the difference between public, static, and void?

923


Define parsing? Explain how to parse a datetime string?

973


Is static thread safe?

887


What is the benefit of dependency injection c#?

908


If you define a user defined data type by using the struct keyword, is it a value type or reference type?

891


What is the difference between ienumerable and enumerable?

924


What is the difference between abstract class and interface in c#?

967


What are some of the commonly used commands in sqlcommand?

915


What is the difference between list and arraylist c#?

1054


What are destructors in C#?

1562


What is signature c#?

933


What is data type in c# with example?

1050


How do I register my code for use by classic com clients?

896


What is a private method in c#?

1053