I am trying to create a function that will automaticall cast the value and
return it based on the parameter. This way say if the value returned from
the DB (or Xml,Text,.etc) is a string "True" I can call the method and use
it like so:
bool mybool = MyClass.MyFCT("searchString",bool); //excuse my newbyness
The same would go for Int32, Int16, DateTime, Double......
I am tring to wrap all the converion in one method without creating a method
for each poosible type.
Thanks!
Ron
"Martin Dechev" <detcheff_@hotmail.com> wrote in message
news:(E-Mail Removed)...
> Hi, Ron Vecchi,
>
> You can create an instance of a type with the static method CreateInstance
> on the System.Activator class. I don't understand what is the connection
> between the string in the DB and the instance or the type.
>
> Hope this helps
> Martin
> "Ron Vecchi" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > If a have a funtion:
> >
> > public object MyFCT(string searchOn, System.Type typ){
> >
> > string foundval;
> >
> > ///foundval is a string pulled from a database
> > /// How can I cast the string into the supplied System.Type typ
> > /// and then return the object?
> >
> > /// Thanks
> >
> > }
> >
> >
>
>
|