将Vb.net转换为C#问题 [英] Converting Vb.net to C# issues

查看:71
本文介绍了将Vb.net转换为C#问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习C#,将一个大型的asp.net项目转换为在vb.net中编写的C#,
并且选项严格被关闭所以这是一个很好的挑战,它< br $>
真的教我C#。


这个项目在VisualBasic命名空间中使用了很多方法。这些

方法真的很有价值,看起来它们可能是有些人说的原因

VB.Net更有效率,C#虽然选项严格转向安全性较低

off。


我的问题是:是否有任何文档可以在任何地方映射C#方法,这些方法与Visualbasic中方法的对应方式相同命名空间?我已经发现

发现String类有很多它们但是有日期函数

以及其他好的地图会派上用场的东西。


谢谢,

T

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,


与C#中通常暴露的函数相比,并不总是一对一地映射函数的原生函数。


我不知道这样的文件,但是如果你在这里发布的方法

你遇到了麻烦,我相信我们可以提供替代方案。


另外,你可以设置对Microsoft.VisualBasic.dll的引用,然后

访问C#中的方法,因为它们只是暴露类的静态方法



希望这会有所帮助。

-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.casp ershouse.com


" Tina" < TI ********** @ nospammeexcite.com>在消息中写道

新闻:OS ************** @ TK2MSFTNGP02.phx.gbl ...
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]
- mv*@spam.guard.caspershouse.com

"Tina" <ti**********@nospammeexcite.com> wrote in message
news:OS**************@TK2MSFTNGP02.phx.gbl...
我正在学习C#通过将一个大的asp.net项目转换为用vb.net编写的C#并且选项严格被关闭,所以这是一个很好的挑战,它真的教我C#。

这个项目在VisualBasic命名空间中使用了很多方法。这些
方法真的很有价值,似乎有些人说这可能是因为VB.Net比C#更高效,但选项严格关闭后安全性较低。
和其他好的地图会派上用场的东西。

谢谢,
T
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



此外,您不会在类方法中发现任何差异,因为.NET Framework类是

语言无关性。你可以在VB.NET中使用的任何String

属性/方法,你在

C#(或任何其他.NET语言)中使用完全相同的方式。


正是出于这个原因,有很多VB.NET开发人员(我自己包含了b $ b),完全不使用Microsoft.VisualBasic命名空间

编写VB.NET代码。相反,我们打开Option Strict并使用.NET

框架类及其属性&方法。例如,使用CStr()代替

,我将使用Object Method .ToString()。与.NET相比,VisualBasic函数的运行方式可能存在差异。

框架类&在某些情况下可能需要更多的代码,但是你最终需要的代码更像面向对象(恕我直言),并且更容易转换成

成为一个问题。


还有那些不同意我的人说你应该使用Microsoft.VisualBasic命名空间,因为那是一个

.NET Framework中的命名空间。


我认为这取决于首选项。在我的情况下,我宁愿把我的遗产与VB 6.0脱节,而不是使用Microsoft.VisualBasic的东西。


HTH

-Scott

Nicholas Paldino [.NET / C#MVP]" < mv*@spam.guard.caspershouse.com>写在

消息新闻:uQ ************** @ TK2MSFTNGP03.phx.gbl ...
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uQ**************@TK2MSFTNGP03.phx.gbl...
Tina,
对于原生VB的函数并不总是一对一的映射,而不是C#中通常暴露的函数。

我不知道我不知道这样的文件,但是如果你在这里发布那些你遇到麻烦的方法,我相信我们可以提供替代方案。

另外,你可以设置一个引用Microsoft.VisualBasic.dll,然后
访问C#中的方法,因为它们只是在Microsoft.VisualBasic命名空间中暴露的静态方法。

希望这个帮助。

-
- Nicholas Paldino [.NET / C#MVP]
- mv*@spam.guard.caspershouse.com

蒂娜 < TI ********** @ nospammeexcite.com>在消息中写道
新闻:OS ************** @ TK2MSFTNGP02.phx.gbl ...
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]
- mv*@spam.guard.caspershouse.com

"Tina" <ti**********@nospammeexcite.com> wrote in message
news:OS**************@TK2MSFTNGP02.phx.gbl...
我正在通过转换来学习C#用VB编写的大型asp.net项目用vb.net和选项严格来关闭,所以这是一个很好的挑战,它真的教我C#。

>这个项目在VisualBasic命名空间中使用了很多方法。这些方法非常有价值,似乎有些人认为VB.Net比C#更高效,但选项严格关闭后安全性较低。
函数和其他东西,好地图会派上用场。

谢谢,
T
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




将Instant C#VB的演示版下载到C#转换器。你可以看到

翻译了多少VisualBasic命名空间方法(我们翻译了

方法在框架中具有一对一的等价物,或几乎

一对一)。

-

David Anton
www.tangiblesoftwaresolutions.com

即时C#:VB到C#转换器

即时VB:C#到VB转换器

即时C ++:C#到C ++转换器& VB到C ++转换器

即时J#:VB到J#转换器


" Tina"写道:
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" wrote:
我正在学习C#,将一个大型的asp.net项目转换为在vb.net中编写的C#,并且选项严格被关闭所以它'这是一个很好的挑战,而且它真的教我C#。

这个项目在VisualBasic命名空间中使用了很多方法。这些方法真的很有价值,似乎有些人说这可能是因为VB.Net的效率更高,而C#虽然不太安全但选项严格关闭了

我的问题是:在任何地方都有任何文档可以映射与Visualbasic命名空间中方法相对应的C#方法吗?我已经发现String类有很多它们但是有日期函数
和其他好的地图会派上用场的东西。

谢谢,
T
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



这篇关于将Vb.net转换为C#问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆