什么是类型参数命名指南? [英] What are the type parameter naming guidelines?

查看:120
本文介绍了什么是类型参数命名指南?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到,以及在 Essential C#3.0 书中看到的那个参数通常被定义为 T TEntity



例如:

  public class Stack< T> 
{


}

或 p>

  public class EntityCollection< TEntity> 
{


}

你怎么样决定使用哪个名称?



谢谢

解决方案

这是我的规则集


  • 如果有一个参数,我将它命名为T $ /
  • 比一个参数,我选择一个有意义的名称和T前缀。例如TKey,TValue



对于一个半官方的意见,它是值得关注的主题框架设计指导方针:


I noticed, as well as saw in the Essential C# 3.0 book, that paramters are usually defined as T or TEntity

For example:

public class Stack<T>
{


}

or

public class EntityCollection<TEntity>
{


}

How do you decide which name to use?

Thanks

解决方案

Here is my set of rules

  • If there is one parameter, I name it T
  • If there is more than one parameter, I pick a meaningful name and prefix with T. For example TKey, TValue

For a semi-official opinion, it's worth looking at the framework design guidelines on the subject:

这篇关于什么是类型参数命名指南?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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