Differentiating in-buit System Types with custom classes in C#
Is there any way by which we differentiate betwe开发者_开发技巧en the in-buit System Types (String, List etc) with custom classes in C# ?
You can use Type.Assembly
to see which assembly it comes from, or you can use Type.Namespace
to get the namespace. The rest depends on your definition of "built-in". For example, you could say that
var builtIn = someType.Namespace.StartsWith("System");
But there is no "hard" definition for what you want.
There is no logical and meaningful difference between built-in types and custom types.
The only difference is that the built-in types reside in the mscorlib
assembly or one of the other framework assemblies. You can check for that, nothing more. However, I would question the usefulness of this information (due to what I said above).
精彩评论