string literals in C#
I have a huge xml file from which the key and value attributes are selected among other things.
How does C# handle the instantiation of literal strings? does it make a new object with allocating heap memory on every iteration or just once?
XmlNode node in
ConfigProductCode cpc = new ConfigProductCode();
XmlAttribute keyAttr = node.Attributes["key"];
XmlAttribute valAttr = node.Attributes["value"];
My understanding is that string literals aren't instantiated. They're just referenced from the assembly. Your method shouldn't incur any runtime cost.
Might I suggest using serialization for the xml file as opposed to parsing it manually through the DOM?