I have this class and i want that to accept a generic as an enum I can pas it in the constructor but I want to use generic.
this is my interface:
public interface ITrnApi<TEnum> : IDisposable where TEnum : struct
and I want my class to be like this one
public class TrnApi<TEnum> : ITrnApi<TEnum> where TEnum : struct
{
private readonly HttpClient _http;
public TrnApi(HttpClient http, TEnum company)
{
_http = http;
_http.BaseAddress = company.ToBaseUrl().ToUri();
//public enum Company
//{
// test = 1,
// othertest = 2
//}
}
}
but get this error:
'TEnum' does not contain a definition for 'ToBaseUrl' and the best extension method overload 'Extentions.ToBaseUrl(Company, string)' requires a receiver of type 'Company'
How can I do that?