Discussion:
static list of strings?
(too old to reply)
SpreadTooThin
2016-07-24 17:15:19 UTC
Permalink
I have a list of string that I need to using in a few places in my program.

List<String> MyKnownFruit = new List<String>() = {"Apples", "Bananas", "Cherries", "Donuts"};


So how should I add this to my application source such that I can use it in one or two places?
Arne Vajhøj
2016-07-24 20:48:17 UTC
Permalink
Post by SpreadTooThin
I have a list of string that I need to using in a few places in my program.
List<String> MyKnownFruit = new List<String>() = {"Apples", "Bananas", "Cherries", "Donuts"};
So how should I add this to my application source such that I can use it in one or two places?
A few possibilities:
- make it public static
- put it in a singleton
- use a DI framework and specify it as singleton scope

Arne
SpreadTooThin
2016-07-25 00:17:31 UTC
Permalink
Post by Arne Vajhøj
Post by SpreadTooThin
List<String> MyKnownFruit = new List<String>() = {"Apples", "Bananas", "Cherries", "Donuts"};
d
Post by Arne Vajhøj
- make it public static
- put it in a singleton
- use a DI framework and specify it as singleton scope
Arne
Bear with me Arne.. I'm new to this language... What? :)
Arne Vajhøj
2016-07-25 00:52:27 UTC
Permalink
Post by SpreadTooThin
Post by Arne Vajhøj
Post by SpreadTooThin
List<String> MyKnownFruit = new List<String>() = {"Apples", "Bananas", "Cherries", "Donuts"};
d
Post by Arne Vajhøj
- make it public static
- put it in a singleton
- use a DI framework and specify it as singleton scope
Bear with me Arne.. I'm new to this language... What?
Public static is just standard attributes on field.

Singleton is a GoF pattern - you can look it up on the
internet - singleton is probably the most discussed
GoF pattern.

DI = Dependency Injection. Examples of such include:
Spring.NET, NInject, StructureMap, Unity, Winsor, LinFu.

Arne

Continue reading on narkive:
Loading...