freelanceprogrammers.org Forum Index » ASP
Problem when converting C# to VB.NET
Joined: 10 Jan 2005
Posts: 3
Problem when converting C# to VB.NET
I`m having trouble when converting code from C# to VB.NET. I`m not
used to C# and am using a translation tool at
http://developerfusion.com/utilities/convertcsharptovb.aspx. The code
I`m translating works fine in the c# program but I get errors when
using it in the VB.NET program & I`m not sure why.
Theres an arraylist called `methods` which is converted to an array
and then getting methodinfo from it.
VS error says "Value of System.Array cannot be converted to
System.Reflection.MethodInfo" yet its ok in C#! The conversion seems
ok from my knowledge.
Below is the C# code followed by the translated VB.NET code:
MethodInfo[] mi = (MethodInfo[])methods.ToArray(typeof(MethodInfo));
ParameterInfo[] pi = mi[drop1.SelectedIndex].GetParameters();
paramInfo = pi;
---------------------------- converted to: -------------------------
Dim mi As MethodInfo = CType(methods.ToArray(GetType(MethodInfo)),
MethodInfo)
Dim pi As ParameterInfo = mi(drop1.SelectedIndex).GetParameters()
Joined: 11 Jan 2006
Posts: 46
Problem when converting C# to VB.NET
Your variables in VB are not dimensioned as arrays as they are in C#.
Try...
Dim mi As MethodInfo() = CType(methods.ToArray(GetType(MethodInfo)),
MethodInfo)
Dim pi As ParameterInfo() = mi(drop1.SelectedIndex).GetParameters()
HTH,
--
Dean Fiala
Very Practical Software, Inc
http://www.vpsw.com
Joined: 10 Jan 2005
Posts: 3
Problem when converting C# to VB.NET
That solves the parameterInfo statement, thanks, but I`m still
getting the same error as before for the MethodInfo bit.
Really not sure why...
--- In AspNetAnyQuestionIsOk@yahoogroups.com, Dean Fiala
<dfiala@g...> wrote:
> Your variables in VB are not dimensioned as arrays as they are in
C#.
> Try...
>
> Dim mi As MethodInfo() = CType(methods.ToArray(GetType(MethodInfo)),
> MethodInfo)
>
> Dim pi As ParameterInfo() = mi(drop1.SelectedIndex).GetParameters()
>
>
> HTH,
>
> --
> Dean Fiala
> Very Practical Software, Inc
> http://www.vpsw.com
Joined: 11 Jan 2006
Posts: 46
Problem when converting C# to VB.NET
Try this...
Dim mi As MethodInfo() =
CType(methods.ToArray(GetType(MethodInfo)),MethodInfo())
On Mon, 10 Jan 2005 13:52:57 -0000, msilver99 <msilver99@...> wrote:
>
>
> That solves the parameterInfo statement, thanks, but I`m still
> getting the same error as before for the MethodInfo bit.
>
> Really not sure why...
>
> --- In AspNetAnyQuestionIsOk@yahoogroups.com, Dean Fiala
> <dfiala@g...> wrote:
> > Your variables in VB are not dimensioned as arrays as they are in
> C#.
> > Try...
> >
> > Dim mi As MethodInfo() = CType(methods.ToArray(GetType(MethodInfo)),
> > MethodInfo)
> >
> > Dim pi As ParameterInfo() = mi(drop1.SelectedIndex).GetParameters()
> >
> >
> > HTH,
> >
> > --
> > Dean Fiala
> > Very Practical Software, Inc
> > http://www.vpsw.com
>
> Yahoo! Groups Links
>
>
>
>
>
--
Dean Fiala
Very Practical Software, Inc
http://www.vpsw.com
Joined: 10 Jan 2005
Posts: 3
Problem when converting C# to VB.NET
Thanks Dean! Works now.
--- In AspNetAnyQuestionIsOk@yahoogroups.com, Dean Fiala
<dfiala@g...> wrote:
> Try this...
>
> Dim mi As MethodInfo() =
> CType(methods.ToArray(GetType(MethodInfo)),MethodInfo())
>
>
> On Mon, 10 Jan 2005 13:52:57 -0000, msilver99 <msilver99@y...>
wrote:
> >
> >
> > That solves the parameterInfo statement, thanks, but I`m still
> > getting the same error as before for the MethodInfo bit.
> >
> > Really not sure why...
> >
> > --- In AspNetAnyQuestionIsOk@yahoogroups.com, Dean Fiala
> > <dfiala@g...> wrote:
> > > Your variables in VB are not dimensioned as arrays as they are
in
> > C#.
> > > Try...
> > >
> > > Dim mi As MethodInfo() = CType(methods.ToArray(GetType
(MethodInfo)),
> > > MethodInfo)
> > >
> > > Dim pi As ParameterInfo() = mi
(drop1.SelectedIndex).GetParameters()
> > >
> > >
> > > HTH,
> > >
> > > --
> > > Dean Fiala
> > > Very Practical Software, Inc
> > > http://www.vpsw.com
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
>
>
> --
> Dean Fiala
> Very Practical Software, Inc
> http://www.vpsw.com
All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help
China Wholesale - Electronics Products
Character Studio - Tutorials and Help







