> After the post, I find the System.Enviorment class is for this purpose.
I realise you aren't using this, but for completeness, I suspect that
this is intended for environment variables
> Now I do come out with my own static class which use Hashtable internally.
Nobody will stop you; but it doesn't seem very elegant; you will have
no assistance to help you know the expected keys or types for
settings. I'm not sure this is buying you much... personally I'd be
more inclined to have a usage-specific class with typed, named
properties (quite probably static).
A final thought; watch out for thread safety and object lifetime
(objects held globally won't be garbage collected, nor will anything
they can see [think "events"]).
Marc
christery@gmail.com - 30 Dec 2007 13:03 GMT
> > After the post, I find the System.Enviorment class is for this purpose.
>
> I realise you aren't using this, but for completeness, I suspect that
> this is intended for environment variables
as in what u see when u type "set" in a command prompt...
hmm...
this could get really complicated... a max len of env var at 255? no,
path can be longer now... but still... would not build hastables
there ;)
and yes, all strings, like WriteLine(Environment.CurrentDirectory);
will tell u where the os thinks u are...
//CY
christery@gmail.com - 30 Dec 2007 13:09 GMT
> and yes, all strings, like WriteLine(Environment.CurrentDirectory);
oh, forgot the point of that.. take 2 programs (same prog) start in
differrent dir and they will tell u different directorys.. I dont
think its shacer or common, initalized by system defaults but can be
set by process
//CY
Marc Gravell - 30 Dec 2007 13:39 GMT
Yes; my point being - I wouldn't go near this for internal application
data (which is what you are talking about).
Marc
Ryan Liu - 30 Dec 2007 15:59 GMT
----- Original Message -----
From: "Marc Gravell" <marc.gravell@gmail.com>
Newsgroups: microsoft.public.dotnet.languages.csharp
Sent: Sunday, December 30, 2007 6:54 PM
Subject: Re: Add a Hashtable to Applicatoin to save Global data
>> After the post, I find the System.Enviorment class is for this purpose.
> I realise you aren't using this, but for completeness, I suspect that
[quoted text clipped - 5 lines]
> no assistance to help you know the expected keys or types for
> settings.
Oh, I come out another enum for keys.
I'm not sure this is buying you much... personally I'd be
> more inclined to have a usage-specific class with typed, named
> properties (quite probably static).
I try to write a generic class to set/get applicaton level variables. (this
class itself does not bind to the enum I mentioned above). By doing this, I
think I can avoid writing more and more classes or adding more and more
properties. And worse when some properties get oboslated.
Ryan
> A final thought; watch out for thread safety and object lifetime
> (objects held globally won't be garbage collected, nor will anything
> they can see [think "events"]).
>
> Marc