Compiler Error CS1948
The range variable 'name' cannot have the same name as a method type parameter
The same declaration space cannot contain two declarations of the same identifier.
- Change the name of the range variable or the type parameter.
The following example generates CS1948 because the identifier T
is used for the range variable and for the type parameter on method TestMethod
:
// cs1948.cs
using System.Linq;
class Test
{
public void TestMethod<T>(T t)
{
var x = from T in Enumerable.Range(1, 100) // CS1948
select T;
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET feedback
.NET is an open source project. Select a link to provide feedback: