Is there a class like java.util.Properties?

  • Thread starter Thread starter Beorne
  • Start date Start date
B

Beorne

Is there a generic Properties class in C# like java.util.properties?
I'd like some class that I can easily write and read from a a file and
that constains <unique_string,string> pairs to be used as a
configuration or parameters or properties file.
I'm working on Compact Framework so I can't use serialization (sob ...)
 
Beorne said:
Is there a generic Properties class in C# like java.util.properties?
I'd like some class that I can easily write and read from a a file and
that constains <unique_string,string> pairs to be used as a
configuration or parameters or properties file.
I'm working on Compact Framework so I can't use serialization (sob ...)

There isn't a built-in class as far as I'm aware, but it would be very
easy to write one - especially if you don't have many requirements
about escaping etc. I'd suggest making the file UTF-8 rather than
ISO-8859-1 as per Java, however - that way you only need to be able to
escape carriage return, line feed, space etc, rather than \uxxxx as
well.
 
Jon said:
I'd suggest making the file UTF-8 rather than
ISO-8859-1 as per Java, however - that way you only need to be able to
escape carriage return, line feed, space etc, rather than \uxxxx as
well.

1.5 can read XML in UTF-8 and 1.6 can read the key=val format
in UTF-8.

Arne
 
Beorne said:
Is there a generic Properties class in C# like java.util.properties?
I'd like some class that I can easily write and read from a a file and
that constains <unique_string,string> pairs to be used as a
configuration or parameters or properties file.
I'm working on Compact Framework so I can't use serialization (sob ...)

Or app config which is probably the true equivalent for
Java properties files.

I think the most .NET'ish way would be to create some code
that reads a XML file in traditional app config format.

Arne
 
Back
Top