Create a class for extension:
public static class Extensions
{
public static string ToXml(this DataSet ds)
{
using (var mStream = new MemoryStream())
{
using (TextWriter sWriter = new StreamWriter(mStream))
{
var xmlSerializer = new XmlSerializer(typeof(DataSet));
xmlSerializer.Serialize(sWriter, ds);
return Encoding.UTF8.GetString(mStream.ToArray());
}
}
}
}
public static class Extensions
{
public static string ToXml(this DataSet ds)
{
using (var mStream = new MemoryStream())
{
using (TextWriter sWriter = new StreamWriter(mStream))
{
var xmlSerializer = new XmlSerializer(typeof(DataSet));
xmlSerializer.Serialize(sWriter, ds);
return Encoding.UTF8.GetString(mStream.ToArray());
}
}
}
}