C# Equivalent to Java "Properties" Class
-
Java's Properties class (http://java.sun.com/javase/6/docs/api/java/util/Properties.html[^]) is an easy way to serialize a bunch of properties to and from a file. I am trying to port a Java application that makes heavy use of this class, to C#. What is the easiest way to emulate this behavior? I thought about XML serialization, but that doesn't work because all the field names have to be specified in advance. Any ideas?
-
Java's Properties class (http://java.sun.com/javase/6/docs/api/java/util/Properties.html[^]) is an easy way to serialize a bunch of properties to and from a file. I am trying to port a Java application that makes heavy use of this class, to C#. What is the easiest way to emulate this behavior? I thought about XML serialization, but that doesn't work because all the field names have to be specified in advance. Any ideas?
How about a Hashtable. The Java properties class extends Java's implementation of a hashtable, so why not use a Hashtable in C# also?
Recent blog posts: * Introduction to LINQ to XML (Part 1) - (Part 2) - (part 3) My website | Blog
-
How about a Hashtable. The Java properties class extends Java's implementation of a hashtable, so why not use a Hashtable in C# also?
Recent blog posts: * Introduction to LINQ to XML (Part 1) - (Part 2) - (part 3) My website | Blog
Hey Colin, That's true, it does extend hashtable - but the real value of the Properties class comes in the utilities it provides for saving/loading that hashtable's contents to streams in different formats (XML, flat file, etc.) This capability is what I am looking for. If I don't find it I'll have to write it and post it here ;)
-
Java's Properties class (http://java.sun.com/javase/6/docs/api/java/util/Properties.html[^]) is an easy way to serialize a bunch of properties to and from a file. I am trying to port a Java application that makes heavy use of this class, to C#. What is the easiest way to emulate this behavior? I thought about XML serialization, but that doesn't work because all the field names have to be specified in advance. Any ideas?
using application/ user settings in c# is at least as easy as properties in java. however, c# settings are serialized in xml, whereas properties are not.