Converting Vb.net to C# issues

  • Thread starter Thread starter Tina
  • Start date Start date
T

Tina

I'm learning C# by converting a large asp.net project to C# that was written
in vb.net and option strict was turned off so it's a nice challenge and it
is really teaching me C#.

This project used a lot of methods in the VisualBasic Namespace. These
methods are really valuable and it seems they might be the reason some say
VB.Net is more productive that C# albeit less safe with option strict turned
off.

My question is: Is there any docs, anywhere, that map C# methods that are
the counterpart of methods in the visualbasic namespace? I have already
found that the String class has a lot of them but there are date functions
and other things where a good map would come in handy.

Thanks,
T
 
Tina,

There isn't always a one-to-one mapping of the functions that are native
VB as opposed to what is typically exposed in C#.

I don't know of such a document, but if you post the methods here that
you are having trouble with, I'm sure we can pose alternatives.

Also, you can set a reference to Microsoft.VisualBasic.dll, and then
access the methods in C#, as they are just static methods exposed of classes
in the Microsoft.VisualBasic namespace.

Hope this helps.
 
In addition, you will not find ANY differences in the class methods since
the .NET Framework classes are language-independant. Any String
properties/methods you could use in VB.NET, you use exactly the same way in
C# (or any other .NET language).

For just this reason, there are many VB.NET developers out there (myself
included), that do not use the Microsoft.VisualBasic Namespace at all when
writing VB.NET code. Instead, we turn Option Strict on and use the .NET
Framework Classes and their properties & methods. For example, instead of
using CStr(), I'd use the Object Method .ToString(). There can be
differences in how the VisualBasic function operates compared to the .NET
Framework Class & more code may be required in some cases, but the code you
wind up with is more Object-Oriented (IMHO) and easier to convert should
that become an issue.

There are also those out there that disagree with me and say that you should
feel free to use the Microsoft.VisualBasic Namespace, because that IS one of
the Namespaces in the .NET Framework.

I think it comes down to preferences. In my case, I'd rather shed my legacy
ties to VB 6.0 and not use Microsoft.VisualBasic stuff at all.

HTH

-Scott


Nicholas Paldino said:
Tina,

There isn't always a one-to-one mapping of the functions that are
native VB as opposed to what is typically exposed in C#.

I don't know of such a document, but if you post the methods here that
you are having trouble with, I'm sure we can pose alternatives.

Also, you can set a reference to Microsoft.VisualBasic.dll, and then
access the methods in C#, as they are just static methods exposed of
classes in the Microsoft.VisualBasic namespace.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Tina said:
I'm learning C# by converting a large asp.net project to C# that was
written in vb.net and option strict was turned off so it's a nice
challenge and it is really teaching me C#.

This project used a lot of methods in the VisualBasic Namespace. These
methods are really valuable and it seems they might be the reason some
say VB.Net is more productive that C# albeit less safe with option strict
turned off.

My question is: Is there any docs, anywhere, that map C# methods that are
the counterpart of methods in the visualbasic namespace? I have already
found that the String class has a lot of them but there are date
functions and other things where a good map would come in handy.

Thanks,
T
 
Download the demo edition of our Instant C# VB to C# converter. You can see
how many of the VisualBasic namespace methods are translated (we translate
the methods the have one-to-one equivalents in the framework, or nearly
one-to-one).
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter & VB to C++ converter
Instant J#: VB to J# converter
 
Tina said:
My question is: Is there any docs, anywhere, that map C# methods that are
the counterpart of methods in the visualbasic namespace? I have already
found that the String class has a lot of them but there are date functions
and other things where a good map would come in handy.

I would use .NET Reflector to see how the VisualBasic assembly methods
are implemented.

-- Barry
 
Is there any way to disable use of the VisualBasic namespace when developing
in VB?
T


Scott M. said:
In addition, you will not find ANY differences in the class methods since
the .NET Framework classes are language-independant. Any String
properties/methods you could use in VB.NET, you use exactly the same way
in C# (or any other .NET language).

For just this reason, there are many VB.NET developers out there (myself
included), that do not use the Microsoft.VisualBasic Namespace at all when
writing VB.NET code. Instead, we turn Option Strict on and use the .NET
Framework Classes and their properties & methods. For example, instead of
using CStr(), I'd use the Object Method .ToString(). There can be
differences in how the VisualBasic function operates compared to the .NET
Framework Class & more code may be required in some cases, but the code
you wind up with is more Object-Oriented (IMHO) and easier to convert
should that become an issue.

There are also those out there that disagree with me and say that you
should feel free to use the Microsoft.VisualBasic Namespace, because that
IS one of the Namespaces in the .NET Framework.

I think it comes down to preferences. In my case, I'd rather shed my
legacy ties to VB 6.0 and not use Microsoft.VisualBasic stuff at all.

HTH

-Scott


Nicholas Paldino said:
Tina,

There isn't always a one-to-one mapping of the functions that are
native VB as opposed to what is typically exposed in C#.

I don't know of such a document, but if you post the methods here that
you are having trouble with, I'm sure we can pose alternatives.

Also, you can set a reference to Microsoft.VisualBasic.dll, and then
access the methods in C#, as they are just static methods exposed of
classes in the Microsoft.VisualBasic namespace.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Tina said:
I'm learning C# by converting a large asp.net project to C# that was
written in vb.net and option strict was turned off so it's a nice
challenge and it is really teaching me C#.

This project used a lot of methods in the VisualBasic Namespace. These
methods are really valuable and it seems they might be the reason some
say VB.Net is more productive that C# albeit less safe with option
strict turned off.

My question is: Is there any docs, anywhere, that map C# methods that
are the counterpart of methods in the visualbasic namespace? I have
already found that the String class has a lot of them but there are date
functions and other things where a good map would come in handy.

Thanks,
T
 
Scott,
You are to be commended! Right now I'm forced to write some VB.NET code in
an ASP.NET 1.1 App that was totally written in VB.NET and can't be converted.
And I keep typing semicolons at the end of each line of code! Yeesh!
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




Scott M. said:
In addition, you will not find ANY differences in the class methods since
the .NET Framework classes are language-independant. Any String
properties/methods you could use in VB.NET, you use exactly the same way in
C# (or any other .NET language).

For just this reason, there are many VB.NET developers out there (myself
included), that do not use the Microsoft.VisualBasic Namespace at all when
writing VB.NET code. Instead, we turn Option Strict on and use the .NET
Framework Classes and their properties & methods. For example, instead of
using CStr(), I'd use the Object Method .ToString(). There can be
differences in how the VisualBasic function operates compared to the .NET
Framework Class & more code may be required in some cases, but the code you
wind up with is more Object-Oriented (IMHO) and easier to convert should
that become an issue.

There are also those out there that disagree with me and say that you should
feel free to use the Microsoft.VisualBasic Namespace, because that IS one of
the Namespaces in the .NET Framework.

I think it comes down to preferences. In my case, I'd rather shed my legacy
ties to VB 6.0 and not use Microsoft.VisualBasic stuff at all.

HTH

-Scott


Nicholas Paldino said:
Tina,

There isn't always a one-to-one mapping of the functions that are
native VB as opposed to what is typically exposed in C#.

I don't know of such a document, but if you post the methods here that
you are having trouble with, I'm sure we can pose alternatives.

Also, you can set a reference to Microsoft.VisualBasic.dll, and then
access the methods in C#, as they are just static methods exposed of
classes in the Microsoft.VisualBasic namespace.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Tina said:
I'm learning C# by converting a large asp.net project to C# that was
written in vb.net and option strict was turned off so it's a nice
challenge and it is really teaching me C#.

This project used a lot of methods in the VisualBasic Namespace. These
methods are really valuable and it seems they might be the reason some
say VB.Net is more productive that C# albeit less safe with option strict
turned off.

My question is: Is there any docs, anywhere, that map C# methods that are
the counterpart of methods in the visualbasic namespace? I have already
found that the String class has a lot of them but there are date
functions and other things where a good map would come in handy.

Thanks,
T
 
No, there is no way to "remove" the built-in reference to the
Microsoft.VisualBasic Assembly in a VB.NET project. It's baked right in.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




Tina said:
Is there any way to disable use of the VisualBasic namespace when developing
in VB?
T


Scott M. said:
In addition, you will not find ANY differences in the class methods since
the .NET Framework classes are language-independant. Any String
properties/methods you could use in VB.NET, you use exactly the same way
in C# (or any other .NET language).

For just this reason, there are many VB.NET developers out there (myself
included), that do not use the Microsoft.VisualBasic Namespace at all when
writing VB.NET code. Instead, we turn Option Strict on and use the .NET
Framework Classes and their properties & methods. For example, instead of
using CStr(), I'd use the Object Method .ToString(). There can be
differences in how the VisualBasic function operates compared to the .NET
Framework Class & more code may be required in some cases, but the code
you wind up with is more Object-Oriented (IMHO) and easier to convert
should that become an issue.

There are also those out there that disagree with me and say that you
should feel free to use the Microsoft.VisualBasic Namespace, because that
IS one of the Namespaces in the .NET Framework.

I think it comes down to preferences. In my case, I'd rather shed my
legacy ties to VB 6.0 and not use Microsoft.VisualBasic stuff at all.

HTH

-Scott


Nicholas Paldino said:
Tina,

There isn't always a one-to-one mapping of the functions that are
native VB as opposed to what is typically exposed in C#.

I don't know of such a document, but if you post the methods here that
you are having trouble with, I'm sure we can pose alternatives.

Also, you can set a reference to Microsoft.VisualBasic.dll, and then
access the methods in C#, as they are just static methods exposed of
classes in the Microsoft.VisualBasic namespace.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I'm learning C# by converting a large asp.net project to C# that was
written in vb.net and option strict was turned off so it's a nice
challenge and it is really teaching me C#.

This project used a lot of methods in the VisualBasic Namespace. These
methods are really valuable and it seems they might be the reason some
say VB.Net is more productive that C# albeit less safe with option
strict turned off.

My question is: Is there any docs, anywhere, that map C# methods that
are the counterpart of methods in the visualbasic namespace? I have
already found that the String class has a lot of them but there are date
functions and other things where a good map would come in handy.

Thanks,
T
 
Mark said:
Unfortunately not.

You and Peter Bromberg both said this. However, I seem to be able in
VB2005 Express to uncheck Microsoft.VisualBasic from the list of
project references, causing lines such as this

Dim d As DateTime = Today

to fail to compile. What gives?

Oh, and what's the C# for 'today' ?
 
You are writing VB.NET (1.1) that was totally written in VB.NET and can't be
converted? Do you mean it *was* VB 6.0 and now needs to be VB.NET?


Peter Bromberg said:
Scott,
You are to be commended! Right now I'm forced to write some VB.NET code in
an ASP.NET 1.1 App that was totally written in VB.NET and can't be
converted.
And I keep typing semicolons at the end of each line of code! Yeesh!
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




Scott M. said:
In addition, you will not find ANY differences in the class methods since
the .NET Framework classes are language-independant. Any String
properties/methods you could use in VB.NET, you use exactly the same way
in
C# (or any other .NET language).

For just this reason, there are many VB.NET developers out there (myself
included), that do not use the Microsoft.VisualBasic Namespace at all
when
writing VB.NET code. Instead, we turn Option Strict on and use the .NET
Framework Classes and their properties & methods. For example, instead
of
using CStr(), I'd use the Object Method .ToString(). There can be
differences in how the VisualBasic function operates compared to the .NET
Framework Class & more code may be required in some cases, but the code
you
wind up with is more Object-Oriented (IMHO) and easier to convert should
that become an issue.

There are also those out there that disagree with me and say that you
should
feel free to use the Microsoft.VisualBasic Namespace, because that IS one
of
the Namespaces in the .NET Framework.

I think it comes down to preferences. In my case, I'd rather shed my
legacy
ties to VB 6.0 and not use Microsoft.VisualBasic stuff at all.

HTH

-Scott


in
message news:[email protected]...
Tina,

There isn't always a one-to-one mapping of the functions that are
native VB as opposed to what is typically exposed in C#.

I don't know of such a document, but if you post the methods here
that
you are having trouble with, I'm sure we can pose alternatives.

Also, you can set a reference to Microsoft.VisualBasic.dll, and then
access the methods in C#, as they are just static methods exposed of
classes in the Microsoft.VisualBasic namespace.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I'm learning C# by converting a large asp.net project to C# that was
written in vb.net and option strict was turned off so it's a nice
challenge and it is really teaching me C#.

This project used a lot of methods in the VisualBasic Namespace.
These
methods are really valuable and it seems they might be the reason some
say VB.Net is more productive that C# albeit less safe with option
strict
turned off.

My question is: Is there any docs, anywhere, that map C# methods that
are
the counterpart of methods in the visualbasic namespace? I have
already
found that the String class has a lot of them but there are date
functions and other things where a good map would come in handy.

Thanks,
T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top