-6

Is there any way through which we can show object size on screen while scaling in and out Object, please give me a simple example thanks.

1
  • I would make your question more clear (what do you mean, size? As in dimensions?), and show at least an attempt and what is not working.
    – L-Four
    Mar 18, 2016 at 11:21

1 Answer 1

3

You can get your object size like this:

public double GetObjectSize(Object Obj)
{
     using (var m = new System.IO.MemoryStream())
     {
     System.Runtime.Serialization.Formatters.Binary.BinaryFormatter b = new
     System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
     b.Serialize(m, Obj);
     double size = Convert.ToDouble(m.Length);
     return size;
    }
}

But consider that not all objects are serializable. And it will not serialize nested objects too deep.

2
  • 3
    Haha, really good answer, you made my day :D Mar 18, 2016 at 11:08
  • Lol, I doubt the memory size was the goal :D
    – derHugo
    Sep 23, 2020 at 14:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.