user3696412
user3696412

Reputation: 1419

C# - Namespace wide instance of class object

I have to read a ini config file in my programm (please no comment's on XML etc. - cannot change that it is a ini) and have a class iniParser that allows me stuff like iniParser.getKey("abc") and so on. I need to access this object in multiple classes in my namespace.

I tried

public static class ConfigIni
{
    iniParser configFileIni = new iniParser("config.ini");
}

but this yield cannot declare instance members in a static class. So I'm looking for another way to make the instance of my iniParser accesible througout the namespace.

Upvotes: 1

Views: 142

Answers (1)

Cosmin
Cosmin

Reputation: 2385

Make the instance static:

public static class ConfigIni
{
    static iniParser configFileIni = new iniParser("config.ini");
}

Upvotes: 3

Related Questions