我应该怎样命名我的泛型类定义文件? [英] What should I name my files with generic class definitions?

查看:375
本文介绍了我应该怎样命名我的泛型类定义文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写一对夫妇,所有的有泛型类型参数的类,但我需要重载类,因为我需要在不同的场景不同数量的参数。基本上,我有

I'm writing a couple of classes that all have generic type arguments, but I need to overload the classes because I need a different number of arguments in different scenarios. Basically, I have

 public class MyGenericClass<T> { ... }
 public class MyGenericClass<T, K> { ... }
 public class MyGenericClass<T, K, L> { ... }
 // it could go on forever, but it won't...

我想他们都在同一个命名空间,但在每类中的一个源文件。我应该命名文件?是否有一个最佳做法?

I want them all in the same namespace, but in one source file per class. What should I name the files? Is there a best practice?

推荐答案

我见过的人使用。

MyGenericClass`1, MyGenericClass`2 or MyGenericClass`3

(数量泛型参数的数量)。

(the number is the number of Generic Parameters).

我认为这就是你作为一个类型名,当你调用的ToString的类。

I think that's what you get as a TypeName when you call .ToString on the class.

这篇关于我应该怎样命名我的泛型类定义文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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