Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Can i define the TSource type in the method of Single()

$
0
0

Hi,

I have an issue of the Single<TSource>()

Why I can't set the TSource of the a concrete type while the collection is the astract type. The following is the example of my question.

public abstract class TestBase

{

}

public class Test : TestBase

{

    public string Code {get; set;}

}

public static void Main(string[] args)

{

    List<TestBase> tests = new List<TestBase>();

    tests.Add(new Test() { Code = "A"});

    Test theTest = tests.Single<Test>();

}

Thanks


Jobria


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>