Input:
public class Foo {
public static <T extends number> boolean isNegative(T number) {
return number.longValue() < 0;
}
}
Output (incorrect):
public class Foo
{
public static bool IsNegative<T extends number>(T number)
{
return number.LongValue() < 0;
}
}
Output (expected; syntactically correct but might be wrong):
public class Foo
{
public static bool IsNegative<T>(T number)
{
return number.LongValue() < 0;
}
}
Note that in this case there is no C# equivalent of constraining a generic type parameter to be a number, but at least we can make it syntactically correct.
Input:
Output (incorrect):
Output (expected; syntactically correct but might be wrong):
Note that in this case there is no C# equivalent of constraining a generic type parameter to be a number, but at least we can make it syntactically correct.