【问题标题】:Serialization of Generic Classes泛型类的序列化
【发布时间】:2014-12-20 23:45:33
【问题描述】:

我有一个名为“City”的班级

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

}

我有一个名为 CityAdd.aspx 的 asp.net 页面,在这个页面中我想创建一个可以存储在视图状态中的城市类的集合。 是否可以使通用集合可序列化?

【问题讨论】:

  • 您是否尝试在视图状态下存储 City 类的集合?有什么例外吗?
  • 最常见的 .NET Framework 集合类型默认可以序列化
  • 在程序集“Classes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”中键入“Project.City”未标记为可序列化。

标签: c# asp.net generics collections


【解决方案1】:

如下,添加Serializable属性

[Serializable] 
public class City
{
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-27
    • 2011-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多