class test<type>
{
public test()
{
}
public bool byteTest()
{
return new byte().Equals(new type()); // Error at new type()
}
}
I want to check whether an anonymous type is a specified type. (like byte)
Why I want to do this something similar like this is I want to limit the anonymous type. Like I just want to declare the anonymous type as a byte or integer.
It looks like you are trying to see if a type parameter (
type) is instantiated as a specific type (byte). If so try the followingThe name
typehere refers to a generic type parameter. An anonymous type in C# refers to a value created via an anonymous type expression. Like soNote: To avoid confusion with the type
Typei would choose a more standard generic argument name likeT,TValue, etc …