freelanceprogrammers.org Forum Index » ASP

Problem when converting C# to VB.NET


View user's profile Post To page top
msilver99 Posted: Mon Jan 10, 2005 6:07 pm


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()
Reply with quote
Send private message
View user's profile Post To page top
kindawords Posted: Mon Jan 10, 2005 7:39 pm


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
Reply with quote
Send private message
View user's profile Post To page top
msilver99 Posted: Mon Jan 10, 2005 7:52 pm


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
Reply with quote
Send private message
View user's profile Post To page top
kindawords Posted: Mon Jan 10, 2005 8:32 pm


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
Reply with quote
Send private message
View user's profile Post To page top
msilver99 Posted: Mon Jan 10, 2005 8:55 pm


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
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

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
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help