Created
October 5, 2013 05:24
-
-
Save howeik/6837044 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| namespace GenericsTest | |
| { | |
| class MainClass | |
| { | |
| public static void Main(string[] args) | |
| { | |
| Console.WriteLine("Hello World!"); | |
| } | |
| } | |
| interface IRequest<T> | |
| { | |
| IResponse<T> GetResponse(); | |
| } | |
| interface IResponse<T> | |
| { | |
| T GetData(); | |
| } | |
| class MyRequest : IRequest<string> | |
| { | |
| public MyResponse GetResponse() | |
| { | |
| return new MyResponse(); | |
| } | |
| } | |
| class MyResponse : IResponse<string> | |
| { | |
| public string GetData() | |
| { | |
| return "abc"; | |
| } | |
| } | |
| } | |
| /* | |
| Error CS0738: `GenericsTest.MyRequest' does not implement interface member `GenericsTest.IRequest<string>.GetResponse()' and the best implementing candidate `GenericsTest.MyRequest.GetResponse()' return type `GenericsTest.MyResponse' does not match interface member return type `GenericsTest.IResponse<string>' (CS0738) (RandomTest) | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment