potzko
Explore posts from servershelp with generic interface
im writing a small binary tree library for fun and ran into a small problem
I made a small interface for Node and Tree:
however the Node interface can only reference itself if that makes sense?
public interface Node<T> where T : IComparable<T>
75 replies
C# enum deconstruction and assosiated data
hi, I want to follow the book crafting interpreters and I don't want to use the exact languadge he uses (java) to avoid copy pasting code without understanding it, I am looking at maybe using C# (I know... super far away from java), however I can't find a feature Ill prob want to use,
is there a way to do rust style enum types with associated data?
think something like (super super psudo code)
8 replies
❔ help with self referential class typing
I was trying to make a node class I can inherit from and ran into a ton of trouble,
in my original solution the "next" value was still a node rather then the child class, I looked around and people were saying to use a self referential generic class signature so I used this:
and started writing, I even got some inheritance to work,
however I ran into a few problems in some of the functions:
in this function for example, how can I make a new "Self" object? as I do not know what constructors it has. and if I try to build a node I cant set it as next as I expect a Self
object, am I missing a trick to get this to work?
9 replies