I've done a fair bit of reading and there are plenty of answers to very similar questions but even following those I can't get this to work. The extension method is static, public, has this
, is in the same namespace so should not need importing... what am I missing? My C# isn't great.
namespace LDB
{
public enum Neg { isNegated, notNegated };
static class NegStringifier {
public static string ToString(this Neg n) {
string res = n switch {
Neg.isNegated => "flowers",
Neg.notNegated => "kittens",
//_ => null
};
return res;
}
}
public class Program
{
static void Main(string[] args)
{
System.Console.WriteLine(Neg.isNegated.ToString());
System.Console.WriteLine(Neg.notNegated.ToString());
...
output:
isNegated
notNegated
Apologies up front, I know this is going to be something trivial but I can't see what.