c# - How to not specify the type argument in a generic method when the required argument is null? -


i have method:

public httprequestmessage createrequest<t>(t genericobject = default(t)) {     ...     if (!equals(genericobject, default(t)))     ... } 

i can call it:

var request = createrequest<int>(); 

seeing don't use default type (i set null default), how can stop defining generic type int(or other type matter) when call method?

edit point is, need specify type , use argument. not need use argument , want set null or 0 instead of writing random type 'int' in example above

you can not, cause that signature of method.

you can create method, has no generic arguments, able call like:

var request = createrequest(); 

Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -