I'm looking for a term descibing the Type that would replace in an explicit implementation of a generic method.

My scenario goes something like this:

I'm happily pair programming with a dude by the name of Kent. Kent writes a explicit implementation of the generic method in question and I want to tell him he's doing it wrong.

public void Foo<______> (______ buzz) 
{
    buzz.Bar();
}

So I say: " Hey Kent, you should change that _ to MyClass"

Could someone please help me replace this __ with something a bit smarter sounding? Maybe a "TargetType", "ExplicitType", or "thingamagig"?

有帮助吗?

解决方案

The term is "generic type parameter".

In a generic type or method definition, a type parameters is a placeholder for a specific type that a client specifies when they instantiate a variable of the generic type.

其他提示

It is a "generic type parameter". From the MSDN introduction to C# generics:

What Are Generics

Generics allow you to define type-safe classes without compromising type safety, performance, or productivity. You implement the server only once as a generic server, while at the same time you can declare and use it with any type. To do that, use the < and > brackets, enclosing a generic type parameter.

It calls Generic Type Parameters

A Generic type parameters is a placeholder for a specific type that a client specifies when they instantiate a variable of the generic type.

Generics in .NET let you reuse code and the effort you put into implementing it.

public void Foo<T> (T buzz) 
{
    buzz.Bar();
}

In the above example a generic Foo of Type "T", where the T is provided by the caller.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top