Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB.NET to C# conversion question

Status
Not open for further replies.

JoeAtWork

Programmer
Jul 31, 2005
2,285
0
0
CA
I'm converting a VB.NET project to C#. The VB.NET project has a module with a number of global variables that are used in different classes. For example, g_UserID is used in 3 different classes.

I am using an online converter to create the C# code. Of course, the global variables do not translate.

I moved all the global variables into a static class, and made the variables public static members.

Is there a way to avoid adding the static class name in front of the static members when used in other classes? I would like to avoid modifying the converted code (I am using an online converter). In other words, I would like to keep using "g_UserID" instead of "StaticClass.g_UserID"?

Joe Schwarz
Custom Software Developer
 
what ever class the static variables are in will be required.
you cannot simply type:
g_UserID

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Thanks. I thought I had read some where that there was a way you could just have the member name and the class would be assumed (similar to something you can do with VB6). I must have been mistaken.

OK, Search & Replace it is then.

Joe Schwarz
Custom Software Developer
 
craigber said:
I'm curious.. why are you converting this app?
To be honest, I don't have the exact reasons. Basically, it's been decided I need to share this assembly with another set of programmers. For whatever reason, they wanted it in C#. In might be because that's what they are fluent in, or perhaps because they want to load the project in VS as part of whatever solution they are working on (and the other projects are in C#).

Joe Schwarz
Custom Software Developer
 
Rewriting the code into C# is not sharing the assembly, it's sharing the code. A C# app can absolutely use an assembly written in VB.Net without converting the code.

Craig Berntson
MCSD, Visual FoxPro MVP,
 
Well, sharing the "assembly code". If they want to load this project and another project under the same solution in VS2008, they both have to be in the same language, don't they? My understanding is that the projects in a VS solution must be in the same language. They don't want to reference the compiled assembly, they want to reference the code so that they can do full debugging.

They will be taking ownership of the project, and their coding is in C# (departmental policy).

Joe Schwarz
Custom Software Developer
 
I'm sure you can register heterogeneous projects in one solution. it's all the same once compiled.

however, I understand them wanting c#. I wouldn't touch VB.Net either

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top