473,397 Members | 1,961 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,397 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 22051
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.