Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mono variance validity issue?
// ContravariantIssue.cs(3,26): error CS1961: The contravariant type parameter `TSomething' must be
// covariantly valid on `ContravariantIssue.In.Mono.Example.IInterface<TSomething>.Something'
namespace ContravariantIssue.In.Mono.Example
{
public interface IInterface<in TSomething>
{
TSomething Something { set; }
}
public interface TSomething
{
string FieldOne { get; set; }
string FieldTwo { get; set; }
}
public class Something : TSomething
{
public string FieldOne { get; set; }
public string FieldTwo { get; set; }
}
public class ContraExample : IInterface<Something>
{
public Something Something { private get; set; }
}
class Program
{
static void Main(string[] args)
{
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.