Home > database >  Is it allowed to use two generic T types (like T and TSource) in C# methods?
Is it allowed to use two generic T types (like T and TSource) in C# methods?

Time:02-11

Is it allowed to use two generic T types (like T and TSource) in C# methods?

public T GetResutls<T>(TSource sourceClass, string jsonString) where TSource : class

CodePudding user response:

Yes, but you have to write both types between the angle brackets:

    public TResult GetResults<TResult, TSource>(TSource source)
    {
       // TODO: Implement your code here
    }
  • Related