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
om prakash
NA
281
104.2k
xml error(serialization)
Jul 22 2013 4:59 AM
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
namespace SimpleXMLSerialize
{
public class Employee
{
public int EID { get; set; }
public string EName { get; set; }
public string Designation { get; set; }
public long Phone { get; set; }
}
public class SXML
{
public static void Main(string[] args)
{
List<Employee> Emplist = new List<Employee>();
Employee emp1 = new Employee();
emp1.EID = 1;
emp1.EName = "Naveen";
emp1.Designation = "QA";
emp1.Phone = 9895356522;
Employee emp2 = new Employee();
emp2.EID = 2;
emp2.EName = "Balu";
emp2.Designation = "Software Developer";
emp2.Phone = 9232546554;
Emplist.Add(emp1);
Emplist.Add(emp2);
Serialize(Emplist);==============>> ERROR
}
public void Serialize(List<Employee> list)
{
XmlSerializer xmlser = new XmlSerializer(typeof(List<
Employee>));
using (StreamWriter stmw = new StreamWriter(@"D:\sxml.xml"))
{
xmlser.Serialize(stmw, list);
}
}
}
I tried for SERIALIZE buit I got error in this line )serialize(emplist)
Error Shows:object reference is required for non static fileds,method or property
}
Reply
Answers (
4
)
How to show separate aspx depends on user entr save and new
xml