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

VB counterpart to C# static constructors?

Can one declare static constructors in VB like one can in C#? In C#, static
constructors execute once before any instances have been created.
Thanks,
Siegfried
Jan 16 '08 #1
4 9117
in a class:

Shared Sub New()
in a Module:

Sub New()
Note: Modules are the equivalent of a Shared (aka static) Class.

"Siegfried Heintze" <si*******@heintze.comwrote in message
news:O4**************@TK2MSFTNGP06.phx.gbl...
Can one declare static constructors in VB like one can in C#? In C#,
static constructors execute once before any instances have been created.
Thanks,
Siegfried
Jan 16 '08 #2
On Jan 16, 1:48 am, "Siegfried Heintze" <siegfr...@heintze.comwrote:
Can one declare static constructors in VB like one can in C#? In C#, static
constructors execute once before any instances have been created.
Thanks,
Siegfried
The answer to your question is "Shared", though the following link
should help you on other C# to VB.NET conversions:

http://www.harding.edu/fmccown/vbnet...omparison.html

Thanks,

Seth Rowe [MVP]
Jan 16 '08 #3
"Siegfried Heintze" <si*******@heintze.comschrieb:
Can one declare static constructors in VB like one can in C#? In C#,
static constructors execute once before any instances have been created.
Constructors: 'Shared Sub New'.
Finalizers:
<URL:http://dotnet.mvps.org/dotnet/articles/sharedfinalizer/SharedFinalizer.zip>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jan 16 '08 #4
"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:b9**********************************@u10g2000 prn.googlegroups.com...
On Jan 16, 1:48 am, "Siegfried Heintze" <siegfr...@heintze.comwrote:
>Can one declare static constructors in VB like one can in C#? In C#,
static
constructors execute once before any instances have been created.
Thanks,
Siegfried

The answer to your question is "Shared", though the following link
should help you on other C# to VB.NET conversions:

http://www.harding.edu/fmccown/vbnet...omparison.html

Thanks,

Seth Rowe [MVP]
That's a great website. When I took a job doing C#, it really saved my
bacon...

RobinS.

Jan 18 '08 #5

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

Similar topics

3
by: Amit | last post by:
is there anything like static constructors or destructors in C++ ? if yes, how to implement it? Thanks, Amit.
7
by: mdc | last post by:
Hi, Is there any way to implement an interface as a static method in C#? If not, is this a bug? Micheal.
9
by: A J Le Couteur Bisson | last post by:
Could someone please confirm that static class constructors are only called at the first use of a non-static constructor on the class, or am I doing something wrong? If this is indeed the case...
6
by: ~~~ .NET Ed ~~~ | last post by:
Yes, I think so at least... In C# you *can* have static properties which are quite useful when used properly. Now imagine the scenario where you need the ability (sp?) to implement a variety of...
17
by: Picho | last post by:
Hi all, I popped up this question a while ago, and I thought it was worth checking again now... (maybe something has changed or something will change). I read this book about component...
12
by: Hemanth | last post by:
Hi, I have a base class with a static constructor and some abstract methods. Derived classes implement these methods. From articles on the web, it appears that there is no guarentee that this...
3
by: Jordan S. | last post by:
Just learning OOP here... Does it make sense to have a constructor in a static class? Say I have a class with a constructor and then mark that class as static; will it (the default constructor) get...
3
by: Adam | last post by:
What happens if one thread is executing a static constructor and another thread starts. Does the second thread block until the first is done in the static constructor? I want to make sure all my...
2
by: Tim Van Wassenhove | last post by:
Hello, When i read the CLI spec, 8.10.2 Method inheritance i read the following: "A derived object type inherits all of the instance and virtual methods of its base object type. It does not...
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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: 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...

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.