开发者

Differentiating in-buit System Types with custom classes in C#

开发者 https://www.devze.com 2023-02-22 23:47 出处:网络
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,

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消