TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Chris Riley
NA
85
0
How to provide class to
from object ?
Sep 16 2010 6:45 AM
Hi,
I am using an XML serializer found on code project, to serialize an object I must provide its type ie;
ObjectXMLSerializer<MyNamespace.MyClass>.Save(new MyNamespace.MyClass(),"filename.xml");
I am experimenting with this and would like to know if it is possible to provide the "class" for the object, if you look at the code below you will see I am passing the class objects type which is invalid, is there anyway I can pass the class here without knowing what class the object is?
if only there were obj.GetClass() ......
public
static
bool
Serialize2File(
object
obj,
string
filename)
{
try
{
ObjectXMLSerializer< obj.GetType() >.Save(obj, filename);
}
catch
(
Exception
ex)
{
return
false
;
}
return
true
;
}
Thanks!
Reply
Answers (
1
)
displaying time of different countries based on country name (gmt)
Asynchronous fileUpLoad control error in ajax tool kit control