ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,201 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello.
How to pass a type to a method as a parameter?
I have this method:
private string CallApi(string api, string method)
{
var client = new RestClient(api);
var request = new RestRequest(method, DataFormat.Json);
var response = client.Get(request);
Employee obj = JsonConvert.DeserializeObject<Employee>(response.Content);
return obj.Descrip;
}
What I want is to receive the type Employee or any other as a parameter so the line Employee obj = ... looks like:
type obj = JsonConvert.DeserializeObject<type>(response.Content);
How to send Employee type as parameter to the method CallAPI:
string CallApi("api", "method", Employee)
Employee is a Model in my project.
Thanks in advance.