Object initializer with explicit interface in C#

Posted by Ben Aston on Stack Overflow See other posts from Stack Overflow or by Ben Aston
Published on 2010-04-05T11:42:53Z Indexed on 2010/04/05 11:53 UTC
Read the original article Hit count: 448

How can I use an object initializer with an explicit interface implementation in C#?

public interface IType
{
  string Property1 { get; set; }
}

public class Type1 : IType
{
  string IType.Property1() { get; set; }
}

...

//doesn't work
var v = new Type1 { IType.Property1 = "myString" };

© Stack Overflow or respective owner

Related posts about c#

Related posts about explicit-interface