Class String
Base class for Perlang strings
Concrete implementations of this string are currently the following:
- AsciiString - a string known to consist of valid ASCII characters only. The uppermost bit in each byte is zero for all characters.
- Utf8String - a string which can contain all Unicode characters, encoded with the UTF-8 encoding.
Namespace: Perlang.Lang
Assembly: Perlang.Stdlib.dll
Syntax
public abstract class String : object
Properties
| Improve this Doc View SourceEmpty
Declaration
public static String Empty { get; }
Property Value
Type | Description |
---|---|
String |
Length
Declaration
public abstract nuint Length { get; }
Property Value
Type | Description |
---|---|
System.UIntPtr |
Newline
Declaration
public static String Newline { get; }
Property Value
Type | Description |
---|---|
String |
Methods
| Improve this Doc View Sourcefrom(Nullable<String>)
Creates a concrete String implementation based on the given CLR string. If the string contains only ASCII characters, an AsciiString will be returned. Otherwise, a Utf8String is returned.
If the given parameter is null
, a null
reference will be returned.
Declaration
public static String from(string? s)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.String> | s | a CLR string. |
Returns
Type | Description |
---|---|
String | A String implementation. |
to_upper()
Declaration
public abstract String to_upper()
Returns
Type | Description |
---|---|
String |
ToString()
Constructs a .NET string based on the given Perlang String.
Declaration
public abstract override string ToString()
Returns
Type | Description |
---|---|
System.String | A new .NET string. |
Remarks
Note that this does not reuse the backing byte buffer for the string; it will cause a new byte buffer to be allocated and the Perlang String to be converted to .NET (UTF-16) format. This method should not be called in performance-critical code, and it should preferably be avoided altogether.