views:

191

answers:

10

A guy came to me there recently with a half done web app that has been created using VB.NET, nothing major, just a normal site. His original programmer couldn't continue so he wants me to finish it. Problem is I don't program using VB.NET nor have I any intention of learning it for a project this small. Usually I would run from something like this but I need the cash. Should I take the project and continue it using C# or just leave it. Has anyone had a similar experience and how did it turn out.

+7  A: 

It can be done, yes. That doesn't mean it will be pretty.

You have two options (as I see it):

  1. Convert the existing code from VB.NET to C# and then complete the application (leaving you with a 100% C# code base).

  2. Migrate the VB.NET logic into a seperate assembly. You can then build that assembly seperate from your C# code and include it as a reference for everything else.

Either way there is probably going to be a good deal of work involved.

Justin Niessner
A: 

If you can compile it to it's own dll you could finish the rest in c#. Or run it through some of the converters out there and fix what's needed.

nportelli
+1  A: 

If it isn't precompiled, I think ASP.NET site projects can mix the language they use because they are compiled before use.

http://www.drdobbs.com/web-development/199701178;jsessionid=IFM3WABNVTC0FQE1GHOSKHWATMY32JVN

To be honest, I would use this as an excuse to get a working understanding of VB.NET - its not difficult and is worth doing.

Adam
As someone who took the time to get a working understanding of VB.NET, I think I'd argue against the idea that it "is worth doing" unless there's a real business need.
spender
Also worth doing because not all code samples are in C# - and from a developer's perspective its again worth doing as you don't know what the codebase is of your next employer.
Adam
+1  A: 

Since you say that it's a small unfinished project I'd just use the free online converters to convert the code from VB.Net to C# automatically. They'll fail sometimes, but most of that will be obvious and either way, you wouldn't trust someone else's half finished code anyway would you? So you'll pretty much have to go through it line by line anyway to see how it works and could then fix any remaining conversion issues.

ho1
+2  A: 

If this is a "Web Site", you can use both C# and VB.NET. See Shared Code Folders in ASP.NET Web Sites at http://msdn.microsoft.com/en-us/library/t990ks23(VS.80).aspx. Code-behind can be either language. As you work on the pages, you can migrate any VB.NET code, if needed.

AMissico
A: 

I think this also depends on the .NET framework version you are using as to what approach you can take.
If it is 1.1 I think your stuck with using VB.NET unless you can separate the additional code needed into a new assembly and reference it from existing project.
If it is a later version of .NET I believe you can mix c# and vb.net classes but obviously not mix languages within classes and pages.
To be honest you are probably better off either converting to c# as has been suggested or taking the plunge and using it as an opportunity to get an understanding of the vb.net syntax.
I'd go with the latter.

Andy Rose
I thought that in Visual Studio.NET, you can always combine modules written in different languages (VB, C++ and C#) in the same project. It would be strange if that was not possible. After all, they all produce the same bytecode.
PauliL
@PauliL That is kind of what I meant by seperating the c# into a new assembly and referencing it. I guess using 'assembly' is a poor choice of words in this scenario and module or project would be better. My point was in 1.1 you can't have one class written in c# and another writter in vb.net in the same project.
Andy Rose
+9  A: 

You can also just bite the bullet and finish it in VB.NET so you don't have to worry about the vagaries of conversion or getting different langs to coexist. i know it doesn't sound palatable but the jump isn't that tough, or even much of a jump. And in the end you'll appreciate C# that much more.

NOTE: Etymology link added for folks who might not be familiar with the "bite the bullet" idiom.

Paul Sasik
+1 Check out the "what is allowed in VB.Net that's prohibited in C#" question for some tips http://stackoverflow.com/questions/966457/what-is-allowed-in-visual-basic-thats-prohibited-in-c-or-vice-versa
MarkJ
@MarkJ: Nice find. Good resource. Though it'd be nice if there was an authoritative article where all of those answers were compiled and formatted somewhat like this: http://www.harding.edu/fmccown/vbnet_csharp_comparison.html#arrays (This web page is open 99.9% in my browser because VB's for loop syntax just does not want to stick in my brain.)
Paul Sasik
Looks useful, led me to another SO question (because one of the answers points to that same link) http://stackoverflow.com/questions/523722/what-are-the-differences-between-c-net-and-visual-basic-net/523757#523757
MarkJ
A: 

Well I haven't used any tools of this kind, but there are enough references to code converter tools like the one above. Maybe you could try it out?

bottlenecked
+1  A: 

If you can move the VB code into a separate assembly and call the functions in that from C# than fine-I would not suggest you have both languages in the same layer for the same app. You need to also think of the support & maintenance of the app too. If it's done in a mix of both VB and C# in the same layer than maintaining the site either for yourself or for someone else is going to be more complex than normal-and could even cost your client more in the long run through this complexity.

DotNetHacker
A: 

You might want to try SharpDevelop's Code Converter. See Offline code converter at http://wiki.sharpdevelop.net/Code%20Converter.ashx.

AMissico