Monotouch creating UIViews with using() blocks
- by Socram
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.