Is it possible for a method to accept any type?
For example can I write:
public ActionResult Edit(? vp){
}
where ActionResult
would accept an Integer, float, or any other (possibly custom) type?
Is it possible for a method to accept any type?
For example can I write:
public ActionResult Edit(? vp){
}
where ActionResult
would accept an Integer, float, or any other (possibly custom) type?
if i understand your meaning so you can use generic like that:
public ActionResult Edit<T>(T vp){ }
T represent the type you want, and whan you call the method give the type in the <>
or you can use object type like this:
public ActionResult Edit(object vp){ }
hope it helped you!
You could use object
and then write a custom model binder for it by overriding the BindModel method which will decide what value to returned based on the request.
public ActionResult Edit(object vp)
{
...
}
Your method can accept an object like so:
public ActionResult Edit(object vp)
{
// you can then cast your object vp to whatever type.
float x = (float)vp;
}