Skip to content

Instantly share code, notes, and snippets.

@ianbattersby
Created August 1, 2012 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianbattersby/3230065 to your computer and use it in GitHub Desktop.
Save ianbattersby/3230065 to your computer and use it in GitHub Desktop.
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