I have a list of key-value pairs that should be shared, but I don't
know how to code it. The trick for me is how to populate it when it's
instantiated.
Herfried got so close to showing me how in a post some while back with
this code...
Private Shared m_Bla As Dictionary = New Dictionary(...)
Private Shared ReadOnly Property Bla() As Dictionary
Get
Return m_Bla
End Get
End Property
But that doesn't show me how to put anything into the list. I'm on the
verge of doing it in C# since Scott Hanselman's recent post (http:// http://www.hanselman.com/blog/Commen...2#commentstart)
showed populating a dictionary object upon instantiation. The same
post, actually, is the same that's motivating me to clean up my code a
bit, namely using a dictionary to map things instead of a big select
(or "switch" in his post).
Thanks! 4 2888
On 2008-06-19, DippyDog <di*******@gmai l.comwrote:
I have a list of key-value pairs that should be shared, but I don't
know how to code it. The trick for me is how to populate it when it's
instantiated.
Herfried got so close to showing me how in a post some while back with
this code...
Private Shared m_Bla As Dictionary
Shared Sub New ()
m_Bla = new Dictionary()
m_Bla.Add("one" , 1)
m_Bla.Add("Two" , 2)
...
End Sub
Private Shared ReadOnly Property Bla() As Dictionary
Get
Return m_Bla
End Get
End Property
HTH
--
Tom Shelton
Dippy Dog,
You cannot instance a shared class or its equivalent a module.
The methods exist as everything simple constantly in your program in memory
as long as your program runs, so you can create a method in the shared class
or module which you use at startup to fill the dictionary.
Cor
"DippyDog" <di*******@gmai l.comschreef in bericht
news:16******** *************** ***********@y38 g2000hsy.google groups.com...
>I have a list of key-value pairs that should be shared, but I don't
know how to code it. The trick for me is how to populate it when it's
instantiated.
Herfried got so close to showing me how in a post some while back with
this code...
Private Shared m_Bla As Dictionary = New Dictionary(...)
Private Shared ReadOnly Property Bla() As Dictionary
Get
Return m_Bla
End Get
End Property
But that doesn't show me how to put anything into the list. I'm on the
verge of doing it in C# since Scott Hanselman's recent post (http:// http://www.hanselman.com/blog/Commen...2#commentstart)
showed populating a dictionary object upon instantiation. The same
post, actually, is the same that's motivating me to clean up my code a
bit, namely using a dictionary to map things instead of a big select
(or "switch" in his post).
Thanks!
On 2008-06-20, Cor Ligthert[MVP] <no************ @planet.nlwrote :
Dippy Dog,
You cannot instance a shared class or its equivalent a module.
The methods exist as everything simple constantly in your program in memory
as long as your program runs, so you can create a method in the shared class
or module which you use at startup to fill the dictionary.
Cor
That's what Shared constructor's (Shared Sub New) is for :)
--
Tom Shelton
Tom,
I was in doubt, did not know if you had misread it, or that I was not aware
that the Sub New could be used as that. I was sure that you would reply as
it was like that.
:-)
Cor
"Tom Shelton" <to*********@co mcastXXXXXXX.ne tschreef in bericht
news:YL******** *************** *******@comcast .com...
On 2008-06-20, Cor Ligthert[MVP] <no************ @planet.nlwrote :
>Dippy Dog,
You cannot instance a shared class or its equivalent a module.
The methods exist as everything simple constantly in your program in memory as long as your program runs, so you can create a method in the shared class or module which you use at startup to fill the dictionary.
Cor
That's what Shared constructor's (Shared Sub New) is for :)
--
Tom Shelton
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Marcelo Rizzo |
last post by:
I am trying to get the name of a file with a specific extension (tmw)
from several different directories. The problem I am having is that
the program stops working on the second pass with an run time error
76. The paths are valid. I tested them and there is a file with the
extension specified.
Any help is appreciated
Marcelo Rizzo
|
by: Dot net work |
last post by:
Hello,
My simple code is here:
Public Class MyDictionary
Inherits System.Collections.DictionaryBase
Private Class MyElement
Public Overloads Overrides Function Equals(ByVal obj As Object) As Boolean
End Function
|
by: tropos |
last post by:
(Platform: Solaris with gmake and native Sun C++ compiler)
Problem: If I create a shared object (.so file) and load it into a
executable, the loader correctly runs constructors of static objects in
the .so file. But if I link the same code statically, with no shared
object, then the constructors don't run at all! Why??
Here's an example:
<file AnnounceConstruction.cpp>
|
by: cj |
last post by:
Public Class MyStringLogger
Private Shared m_loglock As New Object
Public Shared Sub Write(ByVal str As String)
SyncLock (m_loglock)
Dim sw As New System.io.StreamWriter("c:\validate.log",
True)
sw.WriteLine(str)
sw.Close()
End SyncLock
|
by: jzdeng |
last post by:
Hi, All
I use VS 2005 to create a web service. The web service is used to
create a sheared folder. It works fine we I run it from VS 2005. But,
when I move it to inetpub, it does not work (folder is created but is
not shared).
Does anyone know how to solve this problem?
Thanks.
| |
by: cj |
last post by:
members of this type are safe for multithreaded operations. Instance
members are not guaranteed to be thread-safe.
I'm under the impression before you can use a class you have to make an
instance of it. So how can a class be threadsafe by itself but an
instance of it not be?
I guess I don't get what exactly being threadsafe means. Multiple
theads can use the same instance of a class?
|
by: active |
last post by:
The ColorPalette class has no constructor so how does one use it?
I define a variable by:
Dim cp as ColorPalette
but don't know how assign an object to the variable.
Thanks in advance
|
by: =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= |
last post by:
I get the above error in some of the ASP.NET web applications on a
server, and I need some help figuring out how to deal with it.
This is a rather long post, and I hope I have enough details that
someone who bothers to read all of it have some pointers.
Note, I have posted the stack trace and the code exhibiting the problem
further down so if you want to start by reading that, search for +++
Also note that I am unable to reproduce...
|
by: MonkeeSage |
last post by:
A quick question about how python parses a file into compiled
bytecode. Does it parse the whole file into AST first and then compile
the AST, or does it build and compile the AST on the fly as it reads
expressions? (If the former case, why can't functions be called before
their definitions?)
Thanks,
Jordan
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |