M
Meya-awe
Hi,
I am trying to make a generic method which takes as one of its
parameters, a Type. So, i have:
using System; using System.IO; using System.Xml.Serialization;
CreateXml(object o, Type typeOfObj, string filename)
{
... stream declaration..
... xmlserializer declaration
serialXml = new XmlSerializer(typeOfObj);
streamW = new StreamWriter(filename, false);
serialXml.Serialize(streamW, (typeOfObj) o);
....
}
The compiler complains about the last line there where there is a case
of object 0, onto the typeOfObj. What is the correct way to accomplish
this? The compiler message is: the type or namespace 'typeOfObj' coud
not be found (are you missing a directive or an assembly reference?)
thanks,
BRAMOIN
I am trying to make a generic method which takes as one of its
parameters, a Type. So, i have:
using System; using System.IO; using System.Xml.Serialization;
CreateXml(object o, Type typeOfObj, string filename)
{
... stream declaration..
... xmlserializer declaration
serialXml = new XmlSerializer(typeOfObj);
streamW = new StreamWriter(filename, false);
serialXml.Serialize(streamW, (typeOfObj) o);
....
}
The compiler complains about the last line there where there is a case
of object 0, onto the typeOfObj. What is the correct way to accomplish
this? The compiler message is: the type or namespace 'typeOfObj' coud
not be found (are you missing a directive or an assembly reference?)
thanks,
BRAMOIN
.