c# - 将 Objective C 转换为 C# - 此代码的等效项是什么?

标签 c# objective-c xamarin.ios

我正在将一些 Objective C 代码转换为 C#,以便在 Monotouch iPhone 应用程序中使用。

在 Objective C 中,测试了以下等价条件:

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

单元格是一个 UITableViewCell

在 C# 中,我想使用(到目前为止)以下内容测试相同的条件:

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

对 Objective C 代码的理解是否正确,即它测试 cell 的类型? C# 中的等价物是什么?

最佳答案

看起来不错,除非 UITableViewCell 继承自 UIView

在这种情况下你需要

if (cell.BackgroundView.GetType() !=  typeof(UIView))
    ... do something

关于c# - 将 Objective C 转换为 C# - 此代码的等效项是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5995853/

相关文章:

c# - 让 C# 应用程序看起来更漂亮

c# - 在 C# 中减去百分比

C# 在编辑数据网格时更新 MySQL 表不起作用

iOS 7 圆形框架按钮

ios - FontAwesome Pro 和 xamarin.ios 只有一种字体可以激活

silverlight - 是否有 Silverlight/wp7 的 MonoTouch.Dialog 端口?

c# - ActiveMQ可以传输什么样的消息?

objective-c - 如何使用 Swift 中的 AXUIElementCopyAttributeValue?

xamarin - UIKit.UIKitThreadAccessException : UIKit Consistency error: you are calling a UIKit method that can only be invoked from the UI thread

iOS 7 改变了我的界面