没有程序集信息的泛型类型的全名? [英] FullName of generic type without assembly info?

查看:21
本文介绍了没有程序集信息的泛型类型的全名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据库表,用于存储窗口的高度、宽度、状态等.作为窗口的标识符,我使用表单的完整类型名称.它运行良好,但我发现一些通用形式的名称非常长.原因是泛型类型与完整的程序集信息一起列出.有没有办法跳过它?

I have a database table where I store the height, width, state, et cetera, of windows. As identifier for the windows I use the full type name of form. It works well, but I discovered that some forms that are generic gets names which are incredibly long. The reason is that the generic type is listed with full assembly information. Is there a way to skip that?

例如,常规表单的全名如下所示:

For example the full name of a regular form would look like this:

Some.Name.Space.NameOfForm

但是通用表单的全名看起来像这样:

But the full name of a generic form looks like this:

Some.Name.Space.NameOfForm`1[[Some.Other.Name.Space.GenericType, AssemblyName, Version=1.0.2.0, Cuntulre=neutral, PublicKeyToken=null]]

为什么会这么长?有没有办法获得更短的版本?例如类似:

Why does it get so long? Is there a way I can get a shorter version? For example something like:

Some.Name.Space.NameOfForm`1[[Some.Other.Name.Space.GenericType]]

有什么线索吗?

推荐答案

我同意 dbemerlin 的观点,你的最终目标看起来很奇怪,但我只想指出

I agree with dbemerlin in that your end goal seems odd, but I just wanted to point out that

GetType().ToString();

似乎返回了较短版本的类型名(没有泛型参数的程序集信息).

seems to return a shorter version of the typename (w/o the assembly information of the generic arguments).

我想这对于更易读的类型名称版本可能会很方便.

I guess this could be handy for a more human readable version of the type name.

这篇关于没有程序集信息的泛型类型的全名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆