TahaA
✅ where constraint on interface method
Is it even possible? Like
public void RefuelCar<c>(c Car) where c : IUseGas.Refuel
Here the generic type is constrainted to where it implements an interface's method, whereas the name of the interface is IUseGas
22 replies
Is implementing ICloneable in unittests worthless?
ICloneable of course we use to clone reference type variables since they point to the same memory address which implies that any changes to the original reference (like string1) will also change all copies (like string2) that aren't cloned with ICloneable.
Now I haven't used ICloneable in unittests before, but it seems that it doesn't work. Perhaps it is because there's a conflict with other interfaces, or packages in the csproj, all that stuff that on my level (1st year student without foreknowledge) I wouldn't know about, so that's why I'm asking, what are your experiences? Is my hypothesis of internal conflicts possible, or is ICloneable really just worthless on unittests?
2 replies
Can't retrieve data because of JsonIgnore
I'm using JsonIgnore to not include the data in the JSON file (the two properties where I'm using [JsonIgnore] are not allowed to be put inside the JSON file). The problem is that no matter what I've tried until now to retrieve the data in the overriden ToString() method, the datamodel that should contain the TimeTitlePair is always empty/null. I have never had C# up until this semester and this is one of the places where I struggle. I'll show the full code below:
5 replies