Tuesday, 15 September 2015

vb.net - Object Type Converter for varying argued types -



vb.net - Object Type Converter for varying argued types -

say have 2 dictionaries:

dim dict1 new dictionary(of integer, string) dim dict2 new dictioanry(of customtype, customtype2)

i want convert them list in method , homecoming list of argued dictionary value type. so....

public function dicttolistconverter(byval argdict dictionary(of object, object), byval argtype type) **what goes here.

i know can cast homecoming on calling routine, not best solution. not homecoming custom class contains values.in other words i'm looking way following:

pass in dictionary(of integer, string) , homecoming of list(of string)

at same time, if pass in dictionary (of string, boolean) function should homecoming list(of boolean)

it looking not possible , either have utilize class / struct, or cast object in calling routine. wanted verification on whether or not request possible.

again, thanks!

assuming you're using .net 3.5 or later can following...

public function dicttolistconverter(of tkey, t)(dict dictionary(of tkey, t)) list(of t) homecoming dict.select(function(i keyvaluepair(of tkey, t)) i.value).tolist() end function

vb.net list dictionary casting return-type

No comments:

Post a Comment