38 lines
528 B
Plaintext
38 lines
528 B
Plaintext
The best way to determine the type of a generic method is by inference based on the type of argument that is passed to the method. This is not possible when a parameter type is missing from the argument list.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
using System;
|
|
|
|
namespace MyLibrary
|
|
{
|
|
public class Foo
|
|
{
|
|
public void MyMethod<T>() // Noncompliant
|
|
{
|
|
}
|
|
}
|
|
}
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
using System;
|
|
|
|
namespace MyLibrary
|
|
{
|
|
public class Foo
|
|
{
|
|
public void MyMethod<T>(T param)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
----
|
|
|
|
|