Converting from VB .NET to C#

S

stephen

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
 
G

Guest

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.GetConfig("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.getPath[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#
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top