String
Overview
Represents text as a series of Unicode characters. String is immutable (read-only) all methods that modifies content of a string returns a new copy.
Instantinating a String
Please note, that you need to directly specify Sugar.String type when instantinating string by assigning string litteral, for example:
var PlatfromString := "String";
var SugarString: Sugar.String := "String";
Compiler will create an instance of a platform specific string when you are using var
, so in this sample PlatformString
will became a System.String
, java.lang.String
or NSString
depending on your current platform. By specifing a type you will tell compiler to cast string to a Sugar type.
This needed only when declaring string as shown in example, otherwise compiler will cast string litteral automatically, for example:
method DoSomething(Value: Sugar.String);
begin
//Do something
end;
DoSomething("String"); //casted automatically, no need to manually change it
Location
- Reference: Sugar
- Namespace: Sugar
Creates a new instance of the class with specified array.
Parameters:
- Value: Array of byte
- Encoding:
constructor (array of Char)
Creates a new instance of the class with specified array.
constructor(Value: array of Char)
String(Char[] Value)
init(_ Value: Char...)
String(Char[] Value)
Sub New(Value As Char())
Parameters:
- Value: Array of char.
Parameters:
- Value:
- Offset:
- Count:
Parameters:
- aChar:
- aCount:
CharacterIsWhiteSpace
Checks whether specified character is a whitespace.
Parameters:
- Value: Character to check.
Chars
Gets a character withing the string with specified index.
CompareTo mapped
Compares specified String object with the current string. The result is a negative integer if current string precedes the argument string. The result is a positive integer if current string follows the argument string. The result is zero if the strings are equal.
Parameters:
- Value: The string to compare.
CompareToIgnoreCase mapped
Compares specified String object with the current string, ignoring case differences. The result is a negative integer if current string precedes the argument string. The result is a positive integer if current string follows the argument string. The result is zero if the strings are equal.
Parameters:
- Value: The string to compare.
Contains mapped
Returns a value indicating whether a specified substring occurs within this string.
Parameters:
- Value: The string to seek.
EndsWith mapped
Returns a value indicating whether current string ends with a specified string.
Parameters:
- Value: The string to seek.
- IgnoreCase:
Parameters:
- ValueA:
- ValueB:
Determines whether current string and another specified String object have the same value.
Parameters:
- Value: The string to compare.
Parameters:
- ValueA:
- ValueB:
Determines whether current string and another specified String object have the same value, ignoring case differences..
Parameters:
- Value: The string to compare.
Parameters:
- ValueA:
- ValueB:
Parameters:
- Value:
Format
Replaces the format item in a specified string with the string representation of a corresponding object in a specified array.
Each format item takes the following form and consists of the following components: {Index[,Alignment][:FormatSecifier]}
- Index - zero based index in the array.
- Alignment - optional, signed integer indicating the preferred formatted field width. If value is less than the length of the formatted string, alignment is ignored otherwise string is extended with space character either left or right, depending on a sign.
- FormatSpecifier - currently ignored.
Please note, currently string supports only basic formating and align, no data specific transformations will be applied.
String.Format("First {0} Third", 2); //results in "First 2 Third"
String.Format("{0,7}", "Text"); //results in " Text"
String.Format("{0:X4}", 255); //results in "255", format specifier is ignored.
Parameters:
- aFormat: Format of a new string.
- aParams: Array of objects to format.
Parameters:
- Value:
- StartIndex:
Parameters:
- Value:
- StartIndex:
Parameters:
- AnyOf:
Parameters:
- AnyOf:
- StartIndex:
IsNullOrEmpty
Checks whether specified string is nil
or contains no data.
Parameters:
- Value: The string to check.
IsNullOrWhiteSpace
Checks whether specified string is nil
or contains only whit space characters.
Parameters:
- Value: The string to check.
Join
Parameters:
- Separator:
- Values:
Finds the zero-based index of the last occurrence of the specified string in the current string or -1
if it wasn't found.
Parameters:
- Value: The string to seek.
Parameters:
- Value:
Parameters:
- Value:
- StartIndex:
Parameters:
- Value:
- StartIndex:
Length
property Length: Int32 read;
Int32 Length { get; }
var Length: Int32 { get{} }
Int32 Length { __get; }
ReadOnly Property Length() As Int32
PadEnd mapped
Parameters:
- TotalWidth:
- PaddingChar:
PadStart mapped
Parameters:
- TotalWidth:
- PaddingChar:
Replace mapped
Returns a new string in which all occurrences of a specified string in the current instance are replaced with another specified string.
Parameters:
- OldValue: The string to be replaced.
- NewValue: The string to replace with.
Split mapped
Returns a string array that contains the substrings in the current string that are delimited by specified separator.
Parameters:
- Separator: String that delimits the substrings in the current string.
StartsWith mapped
Returns a value indicating whether current string starts with a specified string.
Parameters:
- Value: The string to seek.
- IgnoreCase:
Retrieves a substring from current string. The substring starts at a specified position and continues to the end of the string.
Parameters:
- StartIndex: Starting position of a substring.
Retrieves a substring from current string. The substring starts at a specified position and has specified length.
Parameters:
- StartIndex: Starting position of a substring.
- aLength: The number of characters to be copied.
ToByteArray mapped
Converts current string into a byte array with UTF-8 encoding.
method ToByteArray: array of Byte
Byte[] ToByteArray()
func ToByteArray() -> Byte...
Byte[] ToByteArray()
Function ToByteArray() As Byte()
Parameters:
- aEncoding:
ToCharArray mapped
method ToCharArray: array of Char
Char[] ToCharArray()
func ToCharArray() -> Char...
Char[] ToCharArray()
Function ToCharArray() As Char()
ToLower mapped
Returns a copy of current string converted to lowercase.
method ToLower: not nullable String
String! ToLower()
func ToLower() -> String
String ToLower()
Function ToLower() As String
Returns a copy of current string converted to lowercase.
Parameters:
- aLocale:
ToLowerInvariant mapped
method ToLowerInvariant: not nullable String
String! ToLowerInvariant()
func ToLowerInvariant() -> String
String ToLowerInvariant()
Function ToLowerInvariant() As String
ToUpper mapped
Returns a copy of current string converted to uppercase.
method ToUpper: not nullable String
String! ToUpper()
func ToUpper() -> String
String ToUpper()
Function ToUpper() As String
Returns a copy of current string converted to uppercase.
Parameters:
- aLocale:
ToUpperInvariant mapped
method ToUpperInvariant: not nullable String
String! ToUpperInvariant()
func ToUpperInvariant() -> String
String ToUpperInvariant()
Function ToUpperInvariant() As String
Trim mapped
Removes all leading and trailing white-space characters from the current string.
method Trim: not nullable String
String! Trim()
func Trim() -> String
String Trim()
Function Trim() As String
Parameters:
- TrimChars:
TrimEnd mapped
Parameters:
- TrimChars:
TrimStart mapped
Parameters:
- TrimChars:
Chars
Gets a character withing the string with specified index.
Length
CharacterIsWhiteSpace
Checks whether specified character is a whitespace.
Parameters:
- Value: Character to check.
Parameters:
- ValueA:
- ValueB:
Parameters:
- ValueA:
- ValueB:
Parameters:
- ValueA:
- ValueB:
Format
Replaces the format item in a specified string with the string representation of a corresponding object in a specified array.
Each format item takes the following form and consists of the following components: {Index[,Alignment][:FormatSecifier]}
- Index - zero based index in the array.
- Alignment - optional, signed integer indicating the preferred formatted field width. If value is less than the length of the formatted string, alignment is ignored otherwise string is extended with space character either left or right, depending on a sign.
- FormatSpecifier - currently ignored.
Please note, currently string supports only basic formating and align, no data specific transformations will be applied.
String.Format("First {0} Third", 2); //results in "First 2 Third"
String.Format("{0,7}", "Text"); //results in " Text"
String.Format("{0:X4}", 255); //results in "255", format specifier is ignored.
Parameters:
- aFormat: Format of a new string.
- aParams: Array of objects to format.
IsNullOrEmpty
Checks whether specified string is nil
or contains no data.
Parameters:
- Value: The string to check.
IsNullOrWhiteSpace
Checks whether specified string is nil
or contains only whit space characters.
Parameters:
- Value: The string to check.
Join
Parameters:
- Separator:
- Values:
Creates a new instance of the class with specified array.
Parameters:
- Value: Array of byte
- Encoding:
constructor (array of Char)
Creates a new instance of the class with specified array.
constructor(Value: array of Char)
String(Char[] Value)
init(_ Value: Char...)
String(Char[] Value)
Sub New(Value As Char())
Parameters:
- Value: Array of char.
Parameters:
- Value:
- Offset:
- Count:
Parameters:
- aChar:
- aCount:
CompareTo mapped
Compares specified String object with the current string. The result is a negative integer if current string precedes the argument string. The result is a positive integer if current string follows the argument string. The result is zero if the strings are equal.
Parameters:
- Value: The string to compare.
CompareToIgnoreCase mapped
Compares specified String object with the current string, ignoring case differences. The result is a negative integer if current string precedes the argument string. The result is a positive integer if current string follows the argument string. The result is zero if the strings are equal.
Parameters:
- Value: The string to compare.
Contains mapped
Returns a value indicating whether a specified substring occurs within this string.
Parameters:
- Value: The string to seek.
EndsWith mapped
Returns a value indicating whether current string ends with a specified string.
Parameters:
- Value: The string to seek.
- IgnoreCase:
Determines whether current string and another specified String object have the same value.
Parameters:
- Value: The string to compare.
Determines whether current string and another specified String object have the same value, ignoring case differences..
Parameters:
- Value: The string to compare.
Parameters:
- Value:
Parameters:
- Value:
- StartIndex:
Parameters:
- Value:
- StartIndex:
Parameters:
- AnyOf:
Parameters:
- AnyOf:
- StartIndex:
Finds the zero-based index of the last occurrence of the specified string in the current string or -1
if it wasn't found.
Parameters:
- Value: The string to seek.
Parameters:
- Value:
Parameters:
- Value:
- StartIndex:
Parameters:
- Value:
- StartIndex:
PadEnd mapped
Parameters:
- TotalWidth:
- PaddingChar:
PadStart mapped
Parameters:
- TotalWidth:
- PaddingChar:
Replace mapped
Returns a new string in which all occurrences of a specified string in the current instance are replaced with another specified string.
Parameters:
- OldValue: The string to be replaced.
- NewValue: The string to replace with.
Split mapped
Returns a string array that contains the substrings in the current string that are delimited by specified separator.
Parameters:
- Separator: String that delimits the substrings in the current string.
StartsWith mapped
Returns a value indicating whether current string starts with a specified string.
Parameters:
- Value: The string to seek.
- IgnoreCase:
Retrieves a substring from current string. The substring starts at a specified position and continues to the end of the string.
Parameters:
- StartIndex: Starting position of a substring.
Retrieves a substring from current string. The substring starts at a specified position and has specified length.
Parameters:
- StartIndex: Starting position of a substring.
- aLength: The number of characters to be copied.
ToByteArray mapped
Converts current string into a byte array with UTF-8 encoding.
method ToByteArray: array of Byte
Byte[] ToByteArray()
func ToByteArray() -> Byte...
Byte[] ToByteArray()
Function ToByteArray() As Byte()
Parameters:
- aEncoding:
ToCharArray mapped
method ToCharArray: array of Char
Char[] ToCharArray()
func ToCharArray() -> Char...
Char[] ToCharArray()
Function ToCharArray() As Char()
ToLower mapped
Returns a copy of current string converted to lowercase.
method ToLower: not nullable String
String! ToLower()
func ToLower() -> String
String ToLower()
Function ToLower() As String
Returns a copy of current string converted to lowercase.
Parameters:
- aLocale:
ToLowerInvariant mapped
method ToLowerInvariant: not nullable String
String! ToLowerInvariant()
func ToLowerInvariant() -> String
String ToLowerInvariant()
Function ToLowerInvariant() As String
ToUpper mapped
Returns a copy of current string converted to uppercase.
method ToUpper: not nullable String
String! ToUpper()
func ToUpper() -> String
String ToUpper()
Function ToUpper() As String
Returns a copy of current string converted to uppercase.
Parameters:
- aLocale:
ToUpperInvariant mapped
method ToUpperInvariant: not nullable String
String! ToUpperInvariant()
func ToUpperInvariant() -> String
String ToUpperInvariant()
Function ToUpperInvariant() As String
Trim mapped
Removes all leading and trailing white-space characters from the current string.
method Trim: not nullable String
String! Trim()
func Trim() -> String
String Trim()
Function Trim() As String
Parameters:
- TrimChars:
TrimEnd mapped
Parameters:
- TrimChars:
TrimStart mapped
Parameters:
- TrimChars: