c# - How to put generic Type (T) as parameter? -
i have error:
severity code description project file line error cs0246 type or namespace name 't' not found (are missing using directive or assembly reference?)
on method signature method:
public static void sendmessage(string queuname, t objeto) { queueclient client =queueclient.createfromconnectionstring(connectionstring, "empresa"); brokeredmessage message = new brokeredmessage(objeto); message.contenttype = objeto.gettype().name; client.send(new brokeredmessage(message)); }
you forgot specify type parameter. can in 2 ways:
either define them @ method definition (which way go in case, because method static):
public static void sendmessage<t>(string queuname, t objeto)
or can specify them on class definition (for instance methods):
class myclass<t>{ public void sendmessage(string queuname, t objeto){} }
Comments
Post a Comment