E
ESPNSTI
Hi,
I'm trying to call a static method on a class type that is passed into a
method through generics, for example:
public bool Test<TestStaticType>() where TestStaticType : TestStaticBase,
new()
{
return TestStaticType.Foo(); // <-- The error is produced here
}
It's giving me the following error:
'TestStaticType' is a 'type parameter', which is not valid in the given
context
Why doesn't that work?
FYI, I'm using VS2005 Beta 2.
Thanks,
Erik
________________________________________
using System;
using System.Collections.Generic;
using System.Text;
namespace Test
{
public class TestStaticBase
{
public static bool Foo()
{
return true;
}
}
public class TestStatic : TestStaticBase
{
}
public class Class1
{
public bool Test<TestStaticType>()
where TestStaticType: TestStaticBase, new()
{
return TestStaticType.Foo(); // <-- The error is produced here
}
public void main()
{
bool test = Test<TestStatic>();
}
}
}
I'm trying to call a static method on a class type that is passed into a
method through generics, for example:
public bool Test<TestStaticType>() where TestStaticType : TestStaticBase,
new()
{
return TestStaticType.Foo(); // <-- The error is produced here
}
It's giving me the following error:
'TestStaticType' is a 'type parameter', which is not valid in the given
context
Why doesn't that work?
FYI, I'm using VS2005 Beta 2.
Thanks,
Erik
________________________________________
using System;
using System.Collections.Generic;
using System.Text;
namespace Test
{
public class TestStaticBase
{
public static bool Foo()
{
return true;
}
}
public class TestStatic : TestStaticBase
{
}
public class Class1
{
public bool Test<TestStaticType>()
where TestStaticType: TestStaticBase, new()
{
return TestStaticType.Foo(); // <-- The error is produced here
}
public void main()
{
bool test = Test<TestStatic>();
}
}
}