copycd
copycd

Reputation: 9

How can I cast between interface?

there are interface a, b, c;

// defined. interface d : b, c;

class C1 : a, b, c;

// I want to cast to interface d;

var t = c1 as d;

// t is null.

Upvotes: 1

Views: 48

Answers (1)

Arun Kumar
Arun Kumar

Reputation: 136

d t = c1; 

would do the trick.

For example in

IEnumerable<int> iList = new List<int>();

iList would not have List specific methods such as Add

Upvotes: 1

Related Questions