Monotouch creating UIViews with using() blocks

Posted by Socram on Stack Overflow See other posts from Stack Overflow or by Socram
Published on 2010-06-08T16:37:28Z Indexed on 2010/06/08 16:42 UTC
Read the original article Hit count: 148

Filed under:
|

When i first started using monotouch i found a page with some code samples for simple and frequent tasks... but on some of those code samples i found some things like this one:

var imageRect = new RectangleF(0f, 0f, 320f, 109f);
using (var myImage = new UIImageView(imageRect))
{  
    myImage.Image = UIImage.FromFile("myImage.png");
    myImage.Opaque = true;
    view.AddSubview(myImage);
}

The UIImageView is created inside a using() block.

I'm a .Net developer and i know what a using() does, but i dont understand why is it used on this example. So my question is if this is the best way of creating views, and what are the differences (if any) of this aproach and creating views without the using() block.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about monotouch