0

I have a class named "City"

public class City
{
   public int ID {get; set;}
   public int StateID {get; set;}
   public int CountryID{get; set;}
   public string Name{get; set;}
   .......

}

and i have an asp.net page named CityAdd.aspx, in this page i want to create a collection of city class that can be store in the viewstate. Is it possible to make a Generic Collection Serializable?

3
  • have you try to store collection of City class in view state? any exceptions? Commented Oct 25, 2014 at 6:14
  • Most common .NET Framework collection types can be serialized by default Commented Oct 25, 2014 at 6:17
  • Type 'Project.City' in Assembly 'Classes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable. Commented Oct 25, 2014 at 6:19

1 Answer 1

1

do as below, add Serializable attribute

[Serializable] 
public class City
{
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.