“T"是什么意思在 C# 中是什么意思? [英] What does "T" mean in C#?

查看:49
本文介绍了“T"是什么意思在 C# 中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 VB 背景,为了我的新工作,我正在转换为 C#.总的来说,我也在努力在 .NET 方面变得更好.我已经看到人们发布的示例中经常使用关键字T".C#中的T"是什么意思?例如:

I have a VB background and I'm converting to C# for my new job. I'm also trying to get better at .NET in general. I've seen the keyword "T" used a lot in samples people post. What does the "T" mean in C#? For example:

public class SomeBase<T> where T : SomeBase<T>, new()

T 有什么作用?我为什么要使用它?

What does T do? Why would I want to use it?

推荐答案

它是 泛型类型参数.它也可以是其他东西,例如:

It's a symbol for a generic type parameter. It could just as well be something else, for example:

public class SomeBase<GenericThingy> where GenericThingy : SomeBase<GenericThingy>, new()

只有 T 是 Microsoft 使用和鼓励的默认值.

Only T is the default one used and encouraged by Microsoft.

这篇关于“T"是什么意思在 C# 中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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