Encountered an error in implementing C # exporting the list data to an XML file [with Source]: not accessible because of its level of protection. Only public types can be processed.
The line of code that generated the error:
XmlSerializer XmlSerializer = new XmlSerializer (typeof (List<usermodel>));
Reason for error: class definition in the following code is:
Class Usermodel
No public access modifier added
<summary>///User entity class//////////////////////////NOTE: The class must have the access modifier: public, otherwise an error occurs: Only public types can be processed. </summary> [Serializable] public class Usermodel {private Long id = 1; private string name = "Name"; private int gender = 0; private int age = 20; private string userName = "UserName"; private string password = "password"; Public long ID {get {return Id;} set {id = value;} } public string Name {get {return Name;} set {name = value;} } public int Gender {get {return Gender;} set {gender = value;} } public int Age {get {return-age;} set {age = value;} } public string UserName {get {return UserName;} set {userName = value;} } public string Password {get { return password; } set {password = value;} } }