NSDictionary dictionary = new NSDictionary("name", "John", "age", 30); string name = (string)dictionary.ValueForKey(new NSString("name")); Console.WriteLine(name); // Output: John
class Person : NSObject { public string Name { get; set; } public int Age { get; set; } } Person person = new Person { Name = "John", Age = 30 }; object name = person.ValueForKey(new NSString("Name")); Console.WriteLine(name); // Output: JohnThis example creates a custom class Person which inherits from NSObject, and then creates an instance of this class. The ValueForKey method is used to retrieve the value of the Name property, which is returned as an object. The returned value is then printed to the console. Package library: Xamarin.iOS and Xamarin.Mac