August 2009


There are some things which are seemingly simple but are difficult to get done for the first time at least. This is one of them.

The other day I had to get a Stream from the String I had. Though it was apparently easy, it took me quite a while to figure it out. Nevertheless here’s what I did:

MemoryStream myStream = new MemoryStream(ASCIIEncoding.Default.GetBytes("My String"));

Recently I had a requirement where I had to create an XML file without any definitive structure but from a Class file. I had to write a tag for each class and a child property for each property.

Then instead of going for a primitive method of using the XML Document class, I went for LINQ to XML. The XElement makes life very easy when writing an XML. I just had to write 2 recursive methods to write the entire XML file.

This article helped a lot.