c# - Sending DataType As An Argument? -


i'm trying write method uses following 2 arguments:

columntosort columntype 

the reason want able interpreting 2 things string can give different result comparing same 2 things number. example

string: "10" < "2" double: 10 > 2  

so basically, want able send double or string datatype method argument, don't know how this, seems should possible in c#.

addendum:

what want method like:

insertrow(customdataobj data, int columntosort, datatype datatype){     foreach(var row in listview){         var value1 = (datatype)listview.items[i].subitems[columntosort];         var value2 = (datatype)data.something;         //from here, find data object needs placed in listview , insert     } } 

how called:

i think above provides enough of explanation understand how called, if there specific questions, let me know.  

you can use type parameter type. this

void foo(object o, type t) {  ... } 

and call

double d = 10.0; foo(d, d.gettype()); 

or

foo(d, typeof(double)); 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -