Response<bool,int,string> responseString = new Response<bool,int,string> { Success = true, StatusCode = 200, Data = "{ foo: \"bar\" }" };
Response<bool,int,decimal> responseDecimal = new Response<bool,int,decimal> { Success = true, StatusCode = 200, Data = 19.99M };
Response<bool,int,DateTime> responseDateTime = new Response<bool,int,DateTime> { Success = true, StatusCode = 200, Data = DateTime.Parse("4/13/2015 4:00PM") };
Console.WriteLine(responseString.ToResultString(responseString.Data));
Console.WriteLine(responseDecimal.ToResultString(responseDecimal.Data));
Console.WriteLine(responseDateTime.ToResultString(responseDateTime.Data));
public class Response<T,U,V>
public T Success { get; set; }
public U StatusCode { get; set; }
public V Data { get; set; }
public string ToResultString(V Data)
if(typeof(V) == typeof(string))
result = string.Format("String Response: {0}", Data);
else if (typeof(V) == typeof(decimal))
result = string.Format("Decimal Response: {0}", Data);
else if (typeof(V) == typeof(DateTime))
result = string.Format("DateTime Response: {0}", Data);
result = string.Format("Unknown type Response: {0}", Data);