Class ConstantString
- Namespace
- GLib
- Assembly
- GLib-2.0.dll
This represents an UTF8 string in unmanaged memory. As long as the instance is kept alive the unmanaged memory will not be freed and the handle will be valid.
This is useful in cases where C expects some pointer to a string which is not allowed to be freed. This class can be used to keep a pointer to a string alive as long as needed.
public class ConstantString : IDisposable
- Inheritance
-
ConstantString
- Implements
- Inherited Members
Constructors
ConstantString(string)
Creates a new instance which contains a pointer to a copy of the given string.
public ConstantString(string str)
Parameters
str
stringA string which should be represented in unmanaged memory.
Methods
Dispose()
Releases all unmanaged resources
public void Dispose()
GetHandle()
Retrieves a pointer to the unmanaged memory containing a copy of the original string.
public IntPtr GetHandle()
Returns
- IntPtr
A pointer to unmanaged memory.
GetString()
Creates a new string from the string which is stored in unmanaged memory.
public string GetString()
Returns
- string
The resulting string.