Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting Objective C to C# - What is the equivalent to this code?

I am converting some Objective C code to C# for use in a Monotouch iPhone app.

In Objective C, the following equivalence condition is tested:

if ([cell.backgroundView class] != [UIView class])
    ... do something

cell is a UITableViewCell.

In C#, I'd like to test the same condition using (so far) the following:

if ( !(cell.BackgroundView is UIView))
    ... do something

Is the understanding of the Objective C code correct, i.e. it tests the type of cell? What would the equivalent be in C#?

like image 594
Ryan Avatar asked May 13 '11 17:05

Ryan


1 Answers

Looks right, unless UITableViewCell inherits from UIView.

in which case you'll need

if (cell.BackgroundView.GetType() !=  typeof(UIView))
    ... do something
like image 54
Bala R Avatar answered Oct 21 '22 04:10

Bala R