473,326 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Converting from VB .NET to C#

Hi,
I have been working using VB .NET and I wanted to convert a code to C#
in VB .Net I use modules so that I can declare variables, STP holders so
that I can replace them easily when I move b/w Dev and Prod like this

Module modAVSVariables
'Arraylist and Array Variables
Friend pathArray As Array
Friend temp_arrAllFiles As Array
Friend getPath As ArrayList = New ArrayList

End Module

....................and access them like this in Classes like this:
Public Class HelperClass
Friend Function getPaths() As Boolean
nvc = CType(ConfigurationSettings.GetConfig("Key"),
NameValueCollection)
For Each key As String In nvc.Keys
If nvc(key) = "" Then
_fileError.KeyError("Missing Path", "Key", key)
Return False

Else
getPath.Add(nvc(key))

End If

Next
Return True

End Function

Friend function getFiles() as Boolean
temp_arrAllFiles = System.IO.Directory.GetFiles(getPath(0))

End Function

End Class

.... and so on....
whats the equivalent of "module" in C# where i can declare them....

Thanks,
Stephen
Jul 18 '06 #1
5 1376

"stephen" <st********@hotmail.comwrote in message
news:%2***************@TK2MSFTNGP05.phx.gbl...
Hi,
I have been working using VB .NET and I wanted to convert a code to C#
in VB .Net I use modules so that I can declare variables, STP holders so
that I can replace them easily when I move b/w Dev and Prod like this
Sharpcode has a super Code translator between VB.Net and C#:
http://www.icsharpcode.net/OpenSource/SD/Default.aspx

This will translate it all for you :)
Jul 18 '06 #2
"C# & VB.NET Conversion Pocket Reference" published by O'Reilly is very
useful.
--
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/

"Mischa Kroon" <ww*@bloggingabout.netwrote in message
news:ad***************************@news.chello.nl. ..
>
"stephen" <st********@hotmail.comwrote in message
news:%2***************@TK2MSFTNGP05.phx.gbl...
>Hi,
I have been working using VB .NET and I wanted to convert a code to C#
in VB .Net I use modules so that I can declare variables, STP holders so
that I can replace them easily when I move b/w Dev and Prod like this

Sharpcode has a super Code translator between VB.Net and C#:
http://www.icsharpcode.net/OpenSource/SD/Default.aspx

This will translate it all for you :)


Jul 18 '06 #3

Thanks

"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.comwro te in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
"C# & VB.NET Conversion Pocket Reference" published by O'Reilly is very
useful.
--
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/

"Mischa Kroon" <ww*@bloggingabout.netwrote in message
news:ad***************************@news.chello.nl. ..
>>
"stephen" <st********@hotmail.comwrote in message
news:%2***************@TK2MSFTNGP05.phx.gbl...
>>Hi,
I have been working using VB .NET and I wanted to convert a code to C#
in VB .Net I use modules so that I can declare variables, STP holders so
that I can replace them easily when I move b/w Dev and Prod like this

Sharpcode has a super Code translator between VB.Net and C#:
http://www.icsharpcode.net/OpenSource/SD/Default.aspx

This will translate it all for you :)



Jul 18 '06 #4
A module is basically a class with only static members.
Our Instant C# VB to C# converter produces the following equivalent C# code:

internal static class modAVSVariables
{
//Arraylist and Array Variables
internal static Array pathArray;
internal static Array temp_arrAllFiles;
internal static ArrayList getPath = new ArrayList();
}

public class HelperClass
{
internal bool getPaths()
{
nvc = (NameValueCollection)(ConfigurationSettings.GetCon fig("Key"));
foreach (string key in nvc.Keys)
{
if (nvc(key) == "")
{
_fileError.KeyError("Missing Path", "Key", key);
return false;

}
else
modAVSVariables.getPath.Add(nvc(key));

}
return true;

}

internal bool getFiles()
{
modAVSVariables.temp_arrAllFiles =
System.IO.Directory.GetFiles(modAVSVariables.getPa th[0]);

//INSTANT C# NOTE: Inserted the following 'return' since all code paths
must return a value in C#:
return false;
}

}

--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
C# Code Metrics: Quick metrics for C#
"stephen" wrote:
Hi,
I have been working using VB .NET and I wanted to convert a code to C#
in VB .Net I use modules so that I can declare variables, STP holders so
that I can replace them easily when I move b/w Dev and Prod like this

Module modAVSVariables
'Arraylist and Array Variables
Friend pathArray As Array
Friend temp_arrAllFiles As Array
Friend getPath As ArrayList = New ArrayList

End Module

....................and access them like this in Classes like this:
Public Class HelperClass
Friend Function getPaths() As Boolean
nvc = CType(ConfigurationSettings.GetConfig("Key"),
NameValueCollection)
For Each key As String In nvc.Keys
If nvc(key) = "" Then
_fileError.KeyError("Missing Path", "Key", key)
Return False

Else
getPath.Add(nvc(key))

End If

Next
Return True

End Function

Friend function getFiles() as Boolean
temp_arrAllFiles = System.IO.Directory.GetFiles(getPath(0))

End Function

End Class

.... and so on....
whats the equivalent of "module" in C# where i can declare them....

Thanks,
Stephen
Jul 18 '06 #5
Someone recommended http://www.tangiblesoftwaresolutions.com

I don't have any personal experience with it.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

"stephen" <st********@hotmail.comwrote in message
news:%2***************@TK2MSFTNGP05.phx.gbl...
Hi,
I have been working using VB .NET and I wanted to convert a code to C#
in VB .Net I use modules so that I can declare variables, STP holders so
that I can replace them easily when I move b/w Dev and Prod like this

Module modAVSVariables
'Arraylist and Array Variables
Friend pathArray As Array
Friend temp_arrAllFiles As Array
Friend getPath As ArrayList = New ArrayList

End Module

...................and access them like this in Classes like this:
Public Class HelperClass
Friend Function getPaths() As Boolean
nvc = CType(ConfigurationSettings.GetConfig("Key"),
NameValueCollection)
For Each key As String In nvc.Keys
If nvc(key) = "" Then
_fileError.KeyError("Missing Path", "Key", key)
Return False

Else
getPath.Add(nvc(key))

End If

Next
Return True

End Function

Friend function getFiles() as Boolean
temp_arrAllFiles = System.IO.Directory.GetFiles(getPath(0))

End Function

End Class

... and so on....
whats the equivalent of "module" in C# where i can declare them....

Thanks,
Stephen

Jul 19 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: mustafa | last post by:
Dear sir , I have built my application in visual basic 6.0 and crystal Report8.5 , Now i migrated my application to VB.net using the upgrade wizard.My visual basic form is upgraded to vb.net...
29
by: Armand Karlsen | last post by:
I have a website ( http://www.zen62775.zen.co.uk ) that I made HTML 4.01 Transitional and CSS compliant, and I'm thinking of converting it into XHTML to learn a little about it. Which XHTML variant...
8
by: prabha | last post by:
Hello Everybody, I have to conert the word doc to multiple html files,according to the templates in the word doc. I had converted the word to xml.Also through Exsl ,had finished the multiple...
5
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant...
3
by: Mary | last post by:
Hi, Does anyone know of any software out there that would convert an application written in VBScript to either VB.NET or C#/C++ quite quickly for me, or will I have to re-write the application...
2
by: Map Reader | last post by:
Greetings, I am converting an old VB6 application to use .NET. One of the old controls loads icons from the disk and displays them. However, the transparent color turns to blue somewhere in the...
12
by: Frederik Vanderhaeghe | last post by:
Hi, I have a problem converting text to a double. Why doesn't the code work: If Not (txtdocbedrag.Text = "") Then Select Case ddlBedrag.SelectedIndex Case 0 Case 1
7
by: Tor Aadnevik | last post by:
Hi, I have a problem converting values from Single to double. eg. When the Single value 12.19 is converted to double, the result is 12.1899995803833. Anyone know how to avoid this? Regards...
4
by: gg9h0st | last post by:
i'm a newbie studying php. i was into array part on tutorial and it says i'll get an array having keys that from member variable's name by converting an object to array. i guessed "i can...
2
by: shenanwei | last post by:
DB2 V8.2 on AIX, type II index is created. I see this from deadlock event monitor. 5) Deadlocked Connection ... Participant no.: 2 Lock wait start time: 09/18/2006 23:04:09.911774 .........
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.