Foundation.NSString Class
The Foundation String class.

See Also: NSString Members


[Foundation.Register("NSString", true)]
public class NSString : NSObject, INSMutableCopying, INSSecureCoding, IDisposable

See Also



This is a mapping to the Objective-C NSString class. Generally, in .NET languages you use the native string type in your code. In general, it is not worth using NSString in C#/Mono code as the cost of marshalling is higher when creating NSStrings manually from a C# string than letting the runtime marshal it.

There are a few cases where you will deal with NSString objects in Those are cases where the NSString is used as a handle or token. That means that the underlying platform code is using the address of an NSString as a special handle (the code compares strings not by content, but by the address). In those cases, the NSString has been surfaced in the MonoTouch binding. You will typically find those as Notification constants or key constants.

Another use for NSStrings in C# code is when you want to use some localization APIs exposed in NSStrings that map directly to the underlying platform localization tables.

Code that interoperates with Objective-C automatically converts the internal C# string into an NSString. Sometimes by doing a copy of the string, although the runtime supports zero-copy marshaling of .NET strings as NSStrings as well

Related content


Namespace: Foundation
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: