String String Class

Definition

An immutable sequence of UTF-16 chars.

[Android.Runtime.Register("java/lang/String", ApiSince=1, DoNotGenerateAcw=true)]
public sealed class String : Java.Lang.Object, IDisposable, Java.IO.ISerializable, Java.Lang.ICharSequence, Java.Lang.IComparable, System.Collections.Generic.IEnumerable<char>
type String = class
    inherit Object
    interface ISerializable
    interface IJavaObject
    interface IDisposable
    interface ICharSequence
    interface seq<char>
    interface IEnumerable
    interface IComparable
Inheritance
Attributes
Implements

Remarks

Android platform documentation

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

String() String()

Creates an empty string.

String(Byte[]) String(Byte[])

Converts the byte array to a string using the system's DefaultCharset().

String(Byte[], Charset) String(Byte[], Charset)

Converts the byte array to a String using the given charset.

String(Byte[], Int32) String(Byte[], Int32)

Converts the byte array to a string, setting the high byte of every char to the specified value.

String(Byte[], Int32, Int32) String(Byte[], Int32, Int32)

Converts a subsequence of the byte array to a string using the system's DefaultCharset().

String(Byte[], Int32, Int32, Charset) String(Byte[], Int32, Int32, Charset)

Converts the byte array to a string using the given charset.

String(Byte[], Int32, Int32, Int32) String(Byte[], Int32, Int32, Int32)

Converts the byte array to a string, setting the high byte of every char to high.

String(Byte[], Int32, Int32, String) String(Byte[], Int32, Int32, String)

Converts the byte array to a string using the named charset.

String(Byte[], String) String(Byte[], String)

Converts the byte array to a string using the named charset.

String(Char[]) String(Char[])

Initializes this string to contain the given chars.

String(Char[], Int32, Int32) String(Char[], Int32, Int32)

Initializes this string to contain the given chars.

String(Int32[], Int32, Int32) String(Int32[], Int32, Int32)

Creates a String from the sub-array of Unicode code points.

String(String) String(String)

Constructs a new string with the same sequence of characters as toCopy.

String(StringBuffer) String(StringBuffer)

Creates a String from the contents of the specified StringBuffer.

String(StringBuilder) String(StringBuilder)

Creates a String from the contents of the specified StringBuilder.

Properties

CaseInsensitiveOrder CaseInsensitiveOrder

Compares strings using CompareToIgnoreCase(String).

Class Class

Returns the unique instance of Class that represents this object's class.

(Inherited from Object)
Handle Handle

The handle to the underlying Android instance.

(Inherited from Object)
IJavaObjectEx.IsProxy IJavaObjectEx.IsProxy Inherited from Object
IJavaObjectEx.KeyHandle IJavaObjectEx.KeyHandle Inherited from Object
IJavaObjectEx.NeedsActivation IJavaObjectEx.NeedsActivation Inherited from Object
IJavaPeerable.JniManagedPeerState IJavaPeerable.JniManagedPeerState Inherited from Object
IsEmpty IsEmpty

Returns true if the length of this string is 0.

JniIdentityHashCode JniIdentityHashCode Inherited from Object
JniPeerMembers JniPeerMembers
PeerReference PeerReference Inherited from Object
ThresholdClass ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)
ThresholdType ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)

Methods

CharAt(Int32) CharAt(Int32)

Returns the char at index.

Clone() Clone()

Creates and returns a copy of this Object.

(Inherited from Object)
CodePointAt(Int32) CodePointAt(Int32)

Returns the Unicode code point at the given index.

CodePointBefore(Int32) CodePointBefore(Int32)

Returns the Unicode code point that precedes the given index.

CodePointCount(Int32, Int32) CodePointCount(Int32, Int32)

Calculates the number of Unicode code points between start and end.

CompareTo(String) CompareTo(String)

Compares this string to the given string.

CompareToIgnoreCase(String) CompareToIgnoreCase(String)

Compares this string to the given string, ignoring case differences.

Concat(String) Concat(String)

Concatenates this string and the specified string.

Contains(ICharSequence) Contains(ICharSequence)

Returns true if this string contains the charss from the given CharSequence.

Contains(String) Contains(String)
ContentEquals(ICharSequence) ContentEquals(ICharSequence)

Returns true if the chars in the given CharSequence are the same as those in this string.

ContentEquals(String) ContentEquals(String)
ContentEquals(StringBuffer) ContentEquals(StringBuffer)

Returns true if the chars in the given StringBuffer are the same as those in this string.

CopyValueOf(Char[]) CopyValueOf(Char[])

Creates a new string by copying the given char[].

CopyValueOf(Char[], Int32, Int32) CopyValueOf(Char[], Int32, Int32)

Creates a new string by copying the given subsequence of the given char[].

Dispose() Dispose() Inherited from Object
Dispose(Boolean) Dispose(Boolean) Inherited from Object
EndsWith(String) EndsWith(String)

Compares the specified string to this string to determine if the specified string is a suffix.

Equals(Object) Equals(Object)

Compares this instance with the specified object and indicates if they are equal.

(Inherited from Object)
EqualsIgnoreCase(String) EqualsIgnoreCase(String)

Compares the given string to this string ignoring case.

Format(Locale, String, Object[]) Format(Locale, String, Object[])
Format(String, Object[]) Format(String, Object[])
GetBytes() GetBytes()

Returns a new byte array containing the code points in this string encoded using the system's DefaultCharset().

GetBytes(Charset) GetBytes(Charset)

Returns a new byte array containing the code points of this string encoded using the given charset.

GetBytes(Int32, Int32, Byte[], Int32) GetBytes(Int32, Int32, Byte[], Int32)

Mangles a subsequence of this string into a byte array by stripping the high order bits from each char.

GetBytes(String) GetBytes(String)

Returns a new byte array containing the code points of this string encoded using the named charset.

GetChars(Int32, Int32, Char[], Int32) GetChars(Int32, Int32, Char[], Int32)

Copies the given subsequence of this string to the given array starting at the given offset.

GetEnumerator() GetEnumerator()
GetHashCode() GetHashCode()

Returns an integer hash code for this object.

(Inherited from Object)
IndexOf(Int32) IndexOf(Int32)

Returns the first index of the given code point, or -1.

IndexOf(Int32, Int32) IndexOf(Int32, Int32)

Returns the next index of the given code point, or -1.

IndexOf(String) IndexOf(String)

Returns the first index of the given string, or -1.

IndexOf(String, Int32) IndexOf(String, Int32)

Returns the next index of the given string in this string, or -1.

Intern() Intern()

Returns an interned string equal to this string.

JavaFinalize() JavaFinalize()

Invoked when the garbage collector has detected that this instance is no longer reachable.

(Inherited from Object)
Join(ICharSequence, ICharSequence[]) Join(ICharSequence, ICharSequence[])
Join(ICharSequence, IIterable) Join(ICharSequence, IIterable)
Join(String, IIterable) Join(String, IIterable)
Join(String, String[]) Join(String, String[])
LastIndexOf(Int32) LastIndexOf(Int32)

Returns the last index of the code point c, or -1.

LastIndexOf(Int32, Int32) LastIndexOf(Int32, Int32)

Returns the last index of the code point c, or -1.

LastIndexOf(String) LastIndexOf(String)

Returns the index of the start of the last match for the given string in this string, or -1.

LastIndexOf(String, Int32) LastIndexOf(String, Int32)

Returns the index of the start of the previous match for the given string in this string, or -1.

Length() Length()

Returns the number of chars in this string.

Matches(String) Matches(String)

Tests whether this string matches the given regularExpression.

Notify() Notify()

Causes a thread which is waiting on this object's monitor (by means of calling one of the wait() methods) to be woken up.

(Inherited from Object)
NotifyAll() NotifyAll()

Causes all threads which are waiting on this object's monitor (by means of calling one of the wait() methods) to be woken up.

(Inherited from Object)
OffsetByCodePoints(Int32, Int32) OffsetByCodePoints(Int32, Int32)

Returns the index within this object that is offset from index by codePointOffset code points.

RegionMatches(Boolean, Int32, String, Int32, Int32) RegionMatches(Boolean, Int32, String, Int32, Int32)

Returns true if the given subsequence of the given string matches this string starting at the given offset.

RegionMatches(Int32, String, Int32, Int32) RegionMatches(Int32, String, Int32, Int32)

Returns true if the given subsequence of the given string matches this string starting at the given offset.

Replace(Char, Char) Replace(Char, Char)

Returns a copy of this string after replacing occurrences of the given char with another.

Replace(ICharSequence, ICharSequence) Replace(ICharSequence, ICharSequence)

Returns a copy of this string after replacing occurrences of target replaced with replacement.

Replace(String, String) Replace(String, String)
ReplaceAll(String, String) ReplaceAll(String, String)

Replaces all matches for regularExpression within this string with the given replacement.

ReplaceFirst(String, String) ReplaceFirst(String, String)

Replaces the first match for regularExpression within this string with the given replacement.

SetHandle(IntPtr, JniHandleOwnership) SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
Split(String) Split(String)

Splits this string using the supplied regularExpression.

Split(String, Int32) Split(String, Int32)

Splits this string using the supplied regularExpression.

StartsWith(String) StartsWith(String)

Compares the specified string to this string to determine if the specified string is a prefix.

StartsWith(String, Int32) StartsWith(String, Int32)

Compares the specified string to this string, starting at the specified offset, to determine if the specified string is a prefix.

SubSequence(Int32, Int32) SubSequence(Int32, Int32)
SubSequenceFormatted(Int32, Int32) SubSequenceFormatted(Int32, Int32)

Equivalent to Substring(Int32, Int32) but needed to implement CharSequence.

Substring(Int32) Substring(Int32)

Returns a string containing a suffix of this string starting at start.

Substring(Int32, Int32) Substring(Int32, Int32)

Returns a string containing the given subsequence of this string.

ToArray<T>() ToArray<T>() Inherited from Object
ToCharArray() ToCharArray()

Returns a new char array containing a copy of the chars in this string.

ToLowerCase() ToLowerCase()

Converts this string to lower case, using the rules of the user's default locale.

ToLowerCase(Locale) ToLowerCase(Locale)

Converts this string to lower case, using the rules of locale.

ToString() ToString()
ToUpperCase() ToUpperCase()

Converts this this string to upper case, using the rules of the user's default locale.

ToUpperCase(Locale) ToUpperCase(Locale)

Converts this this string to upper case, using the rules of locale.

Trim() Trim()

Returns a string with no code points <= \u0020 at the beginning or end.

UnregisterFromRuntime() UnregisterFromRuntime() Inherited from Object
ValueOf(Boolean) ValueOf(Boolean)

Converts the specified boolean to its string representation.

ValueOf(Char) ValueOf(Char)

Returns a new string of just the given char.

ValueOf(Char[]) ValueOf(Char[])

Returns a new string containing the same chars as the given array.

ValueOf(Char[], Int32, Int32) ValueOf(Char[], Int32, Int32)

Returns a new string containing the same chars as the given subset of the given array.

ValueOf(Double) ValueOf(Double)

Returns the string representation of the given double.

ValueOf(Int32) ValueOf(Int32)

Returns the string representation of the given int.

ValueOf(Int64) ValueOf(Int64)

Returns the string representation of the given long.

ValueOf(Object) ValueOf(Object)

Converts the specified object to its string representation.

ValueOf(Single) ValueOf(Single)

Returns the string representation of the given float.

Wait() Wait()

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.

(Inherited from Object)
Wait(Int64) Wait(Int64)

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the specified timeout expires.

(Inherited from Object)
Wait(Int64, Int32) Wait(Int64, Int32)

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the specified timeout expires.

(Inherited from Object)

Explicit Interface Implementations

IComparable.CompareTo(Object) IComparable.CompareTo(Object)
IEnumerable.GetEnumerator() IEnumerable.GetEnumerator()
IJavaObjectEx.ToLocalJniHandle() IJavaObjectEx.ToLocalJniHandle() Inherited from Object
IJavaPeerable.Disposed() IJavaPeerable.Disposed() Inherited from Object
IJavaPeerable.DisposeUnlessReferenced() IJavaPeerable.DisposeUnlessReferenced() Inherited from Object
IJavaPeerable.Finalized() IJavaPeerable.Finalized() Inherited from Object
IJavaPeerable.SetJniIdentityHashCode(Int32) IJavaPeerable.SetJniIdentityHashCode(Int32) Inherited from Object
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) Inherited from Object
IJavaPeerable.SetPeerReference(JniObjectReference) IJavaPeerable.SetPeerReference(JniObjectReference) Inherited from Object

Extension Methods

JavaCast<TResult>(IJavaObject) JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject) JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable) GetJniTypeName(IJavaPeerable)
SubSequence(ICharSequence, Int32, Int32) SubSequence(ICharSequence, Int32, Int32)

Applies to