Impossibile effettuare il marshalling del tipo System.Collections.Generic.List`1[TurismoModelPackage.Category] come struttura non gestita. Non è possibile calcolare una dimensione o un offset significativo.
using System; using System.IO; using System.Runtime.Serialization.Formatters.Binary; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { Person p = new Person("fabri", "ca",38); Console.WriteLine(GetSizeOfObject(p)); Console.Read(); } private static long GetSizeOfObject(object obj) { long size = 0; using (Stream s = new MemoryStream()) { BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(s, obj); size = s.Length; } return size; } } [Serializable] public class Person { public String Nome { get; set; } public String Cognome { get; set; } public Int16 Age { get; set; } public Person(String Nome, String Cognome,Int16 Age) { this.Nome = Nome; this.Cognome = Cognome; this.Age = Age; } } }
Torna al forum | Feed RSS