日期:2014-05-17  浏览次数:20918 次

关于序列化,这段代码中,为什么要info.GetInt32()?
protected GraphicsList(SerializationInfo info, StreamingContext context)
        {
            graphicsList = new DrawList();
 
            int n = info.GetInt32(entryCount);
            string typeName;
            DrawObject drawObject;
 
            for (int i = 0; i < n; i++)
            {
                typeName = info.GetString(String.Format(CultureInfo.InvariantCulture,"{0}{1}",entryType, i));
 
                drawObject = (DrawObject)Assembly.GetExecutingAssembly().CreateInstance(
                    typeName);
 
                drawObject.LoadFromStream(info, i);
 
                graphicsList.Add(drawObject);
            }
 
        }

------解决方案--------------------
GetInt32 从 SerializationInfo 存储区中检索一个 32 位有符号整数值。