c# - Cannot implicitly convert type Interface to 'System.Collections.Generic.IList<T>' -


stuck in below issue please help, have 1 below class , contain 1 method return type interface

public class helper {      public irestresponse getcam (string searchterm, int page, int pagesize)     {        restrequest request = new restrequest(method.get)                              {                                requestformat = dataformat.json,                                resource = string.format("/assets/campaigns?search={0}&page={1}&count={2}&depth=complete",                                searchterm, page, pagesize)                               };        irestresponse response = _client.execute(request);        return response;     } } 

in interface have set,

public interface irestresponse     {         string content { get; set; }         string contentencoding { get; set; }         long contentlength { get; set; }         string contenttype { get; set; }         ilist<restresponsecookie> cookies { get; }         exception errorexception { get; set; }         string errormessage { get; set; }         ilist<parameter> headers { get; }         irestrequest request { get; set; }         responsestatus responsestatus { get; set; }         uri responseuri { get; set; }      } } 

now when call helper class in program below giving me error :

"cannot implicitly convert type 'restsharp.irestresponse' 'system.collections.generic.ilist>'. explicit conversion exists (are missing cast?)"

my calling program have below code

camsample.helper f = new campaignhelper("company name", "username", "password", "sitename"); ilist<campaignsample.models.irestresponse> q = new list<campaignsample.models.irestresponse>(); //list<irestresponse<campaignsample.models.campaign>> w = new ilist<irestresponse<campaignsample.models.campaign>>().tolist(); q = f.getcam("", 1, 200); 

--- getting error here please tell me solution

your method returning iresponse object not list<iresponse> object, shoud writing when calling:

campaignsample.models.irestresponse response = f.getcam("", 1, 200); 

or can make use of var here:

var response = f.getcam("", 1, 200); 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -