I would like to have a function could write to a file any class instance that was passed to it.

I read up on seralization, but found that it doesn't work with generics.
Is there any functions/classes in the standard .net library or will I need to write my own stuff.
I'm thinking a recursive function that enumerates fields/methods of a class and records the values for those in an XML-like file.