akaJB
akaJB
CC#
Created by akaJB on 7/30/2023 in #help
✅ Confusion over defining a default implementation on an interface
Thank you for the long reply. That all makes sense and clears up my confusion.
6 replies
CC#
Created by akaJB on 7/29/2023 in #help
✅ How do I deal with generic covariance and collections types?
Can you verify if I'm I misunderstanding something? It seems to not compile:
using System.Collections.Generic;

namespace Test
{
public interface IBox
{
}

public interface IBoxCollection<out T>
where T : IBox
{
IReadOnlyDictionary<string, T> Collection { get; }
}
}
using System.Collections.Generic;

namespace Test
{
public interface IBox
{
}

public interface IBoxCollection<out T>
where T : IBox
{
IReadOnlyDictionary<string, T> Collection { get; }
}
}
https://dotnetfiddle.net/v9UvPa
8 replies
CC#
Created by akaJB on 7/28/2023 in #help
❔ Attempting to create a Result<T, E> type, running into issues with subclasses
In my defense it's late, but I'm having a hard time understanding how to implement a result type via contravariant/covariance. Would you have a real world example of these concepts in practice? Fwiw I plan on looking at it in the morning with fresh eyes
9 replies