简体   繁体   English

将ASP.NET项目从Visual Basic切换到C#

[英]Switch ASP.NET Project From Visual Basic to C#

Is there a way to change the language of an ASP.NET project from Visual Basic to C# easily? 有没有一种方法可以轻松地将ASP.NET项目的语言从Visual Basic更改为C#? I would even be willing to re-write the code as it's still fairly simple at this point. 我什至愿意重写代码,因为此时代码仍然相当简单。

The language you choose to implement in can be either Visual Basic or C#. 您选择实现的语言可以是Visual Basic或C#。 And, as far as I know, recoding those pages is the only way to go about doing it. 而且,据我所知,重新编码这些页面是执行此操作的唯一方法。 There is nothing special you have to do with the actual project - you basically just choose to have a C# code-behind rather than a Visual Basic. 与实际项目没有什么特别的关系-您基本上只是选择隐藏C#代码而不是Visual Basic。

Of course, I would have to ask WHY you want to do this. 当然,我不得不问为什么要这样做。 If your site is already working in Visual Basic, is there some pressing need to do this? 如果您的站点已经在Visual Basic中运行,是否有迫切需要执行此操作? Matter of preference? 优先事项? No matter what, it can be done (fairly) easily, as long as you understand the code well enough to translate between the two. 无论如何,只要您对代码的理解足够好,可以在两者之间进行转换,就可以轻松(相当)地完成此操作。

There's various converters out there , but the one I've liked the best is SharpDevelop 's - using that IDE, you can do Tools -> Convert . 各种各样的转换器 ,但是我最喜欢的转换器SharpDevelop的-使用该IDE,您可以执行Tools-> Convert If you just want to convert a snippet, you can use their online converter too. 如果您只想转换代码段,也可以使用其在线转换器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM