473,396 Members | 1,924 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,396 software developers and data experts.

vb module equivelent in C#

I store all my global functions in modules when using vb. What is the
equivelent convention in C#. I am converting a .net compact frmwk project
from vb to C#.

Thanx,
Poe
Nov 16 '05 #1
7 22050
You can't have a module, which I think is a good thing. Everything has to be
in a class. Static members are accessible without creating an instance of the
class, and constants are obviously static. So just have a class called
'Consts', and say:
public class consts
{
public const string APP_NAME = "TheApp";
}

public class Class1
{
[STAThread]
public static void Main(string[] args)
{
Console.WriteLine("I'm {0}", Consts.APP_NAME);
}
}
"Poewood" wrote:
I store all my global functions in modules when using vb. What is the
equivelent convention in C#. I am converting a .net compact frmwk project
from vb to C#.

Thanx,
Poe

Nov 16 '05 #2

"Poewood" <Po*****@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com...
I store all my global functions in modules when using vb. What is the
equivelent convention in C#. I am converting a .net compact frmwk project
from vb to C#.

Thanx,
Poe


In addition to what Patty has told you, I would consider making the class
sealed, so it cannot be used as a base class. Declare all your methods
static, so calls can be qualified with the class name.

--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
Nov 16 '05 #3
Thanx Peter. How do you "seal" a class?

"Peter van der Goes" wrote:

"Poewood" <Po*****@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com...
I store all my global functions in modules when using vb. What is the
equivelent convention in C#. I am converting a .net compact frmwk project
from vb to C#.

Thanx,
Poe


In addition to what Patty has told you, I would consider making the class
sealed, so it cannot be used as a base class. Declare all your methods
static, so calls can be qualified with the class name.

--
Peter [MVP Visual Developer]
Jack of all trades, master of none.

Nov 16 '05 #4
Merci beaucoup Patty!!! You're a great help.

Another question: If I want to declare Static functions, do I have to
include the constant "[STAThread]".

"Patty O'Dors" wrote:
You can't have a module, which I think is a good thing. Everything has to be
in a class. Static members are accessible without creating an instance of the
class, and constants are obviously static. So just have a class called
'Consts', and say:
public class consts
{
public const string APP_NAME = "TheApp";
}

public class Class1
{
[STAThread]
public static void Main(string[] args)
{
Console.WriteLine("I'm {0}", Consts.APP_NAME);
}
}
"Poewood" wrote:
I store all my global functions in modules when using vb. What is the
equivelent convention in C#. I am converting a .net compact frmwk project
from vb to C#.

Thanx,
Poe

Nov 16 '05 #5
"Poewood" <Po*****@discussions.microsoft.com> ëúá
áäåãòä:58**********************************@micros oft.com...
Merci beaucoup Patty!!! You're a great help.

Another question: If I want to declare Static functions, do I have to
include the constant "[STAThread]".

[STAThread] is NOT a constant, rather it's an attribute applied to to the
static Main method.
It has no bearing on the static class 'consts' as shown in Patty's example.
Nov 16 '05 #6
"Poewood" <Po*****@discussions.microsoft.com> wrote in message
news:B7**********************************@microsof t.com...
Thanx Peter. How do you "seal" a class?


By using the *sealed* reserverd word e.g.

namespace myNameSpace
{

public class CSealedNo
{
// do something
}

public sealed class CSealedYes
{
// do something else
}

}
Nov 16 '05 #7
It was just to try and illustrate that this function is intended to represent
the entry point function that's given to you by the IDE.

"Opher Shachar" wrote:
"Poewood" <Po*****@discussions.microsoft.com> ëúá
áäåãòä:58**********************************@ microsoft.com...
Merci beaucoup Patty!!! You're a great help.

Another question: If I want to declare Static functions, do I have to
include the constant "[STAThread]".

[STAThread] is NOT a constant, rather it's an attribute applied to to the
static Main method.
It has no bearing on the static class 'consts' as shown in Patty's example.

Nov 16 '05 #8

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

Similar topics

8
by: Bo Peng | last post by:
Dear list, I am writing a Python extension module that needs a way to expose pieces of a big C array to python. Currently, I am using NumPy like the following: PyObject* res =...
5
by: dody suria wijaya | last post by:
I found this problem when trying to split a module into two. Here's an example: ============== #Module a (a.py): from b import * class Main: pass ============== ==============
8
by: bryan | last post by:
Is there any way I can get the application path (the one returned by Request.ApplicationPath) in the Application_Start method in Global.asax? Request is not valid there. On a related note, is there...
3
by: rss | last post by:
set rowcount 1 select Idnum1,Idnum3 from mytable order by Idnum1 DESC, idnum3 ASC is equivelent to select first(Idnum1),first(idnum3) from mytable order by first(Idnum1) DESC...
10
by: Dave Cox | last post by:
of "int" in VB? //b=1.2 b=int(b) //b now equals 1
7
by: lathamik | last post by:
Does anyone know of the vb.net equivelent to the c# continue so I can exit the immediate iteration of a for loop and continue with the next one.
23
by: pirata | last post by:
I'm a bit confusing about whether "is not" equivelent to "!=" if a != b: ... if a is not b: ... What's the difference between "is not" and "!=" or they are the same thing?
21
by: Mike N. | last post by:
Can someone tell me if there is a C# equivelent to the VBA 'with' statement that works like this: Set myControl = CommandBars(PopUpToUse).Controls.Add(msoControlButton, before:=5) With...
0
by: Fredrik Lundh | last post by:
Jeff Dyke wrote: so how did that processing use the "mymodulename" name? the calling method has nothing to do with what's considered to be a local variable in the method being called, so...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.