how can i compare between two objects using getType method
i want to know if two objects are from the same class or from the same base class
emilio
10
Junior Poster
Recommended Answers
Jump to PostTo get object type
Program p = new Program(); Console.WriteLine(p.GetType().Name);//prints Program
To get object base type
Program p = new Program(); Console.WriteLine(p.GetType().BaseType.Name);//prints Object (the base class of Program class)
To compare between two objects you just need to use string.Compare....
All 9 Replies
Ramy Mahrous
401
Postaholic
Featured Poster
emilio
10
Junior Poster
Ramy Mahrous
401
Postaholic
Featured Poster
serkan sendur
821
Postaholic
Banned
serkan sendur
821
Postaholic
Banned
Ramy Mahrous
401
Postaholic
Featured Poster
serkan sendur
821
Postaholic
Banned
Ramy Mahrous
401
Postaholic
Featured Poster
serkan sendur
821
Postaholic
Banned
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.