Skip to content

Instantly share code, notes, and snippets.

@howeik
Created October 5, 2013 05:24
Show Gist options
  • Select an option

  • Save howeik/6837044 to your computer and use it in GitHub Desktop.

Select an option

Save howeik/6837044 to your computer and use it in GitHub Desktop.
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