How to check if particular class is user defined?
-
Hi All, I am writing an application in which I need to put check if a class is user defined or built in (C# or .Net). Can someone help me with this? Thanks, AksharRoop
-
Hi All, I am writing an application in which I need to put check if a class is user defined or built in (C# or .Net). Can someone help me with this? Thanks, AksharRoop
-
This might not be the ideal solution, but you can get the namespace of a type. You could check whether the class part of the "System" or "Microsoft" namespaces :)
I are Troll :suss:
Thanks but I need better solution if any .. :)
-
Hi All, I am writing an application in which I need to put check if a class is user defined or built in (C# or .Net). Can someone help me with this? Thanks, AksharRoop
There is no way to reliably tell. All classes in the .NET Framework are "user defined".
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009... -
Hi All, I am writing an application in which I need to put check if a class is user defined or built in (C# or .Net). Can someone help me with this? Thanks, AksharRoop
-
Hi All, I am writing an application in which I need to put check if a class is user defined or built in (C# or .Net). Can someone help me with this? Thanks, AksharRoop
You could get the assembly attributes at runtime and check the publisher's name and or copyright notice for 'Microsoft'. Obviously this is not rock solid, but if you want that, the only verifiable way I can think of at the moment is to build a dictionary of all the .NET assemblies and their hash digests (See Assembly.Evidence), then verify the assembly against your dictionary. Not pretty.