Attempts to concatenate individual path components to a preallocated character span, and returns a value that indicates whether the operation succeeded.
OverloadsThe destination character span must be large enough to hold the concatenated path. You can then retrieve the concatenated path by calling the Span<T>.Slice method, as the following example illustrates.
using System;
using System.IO;
class Program
{
static void Main()
{
int nChars = 0;
var buffer = new Span<Char>(new String(' ', 100).ToCharArray());
var flag = Path.TryJoin("C:/".AsSpan(), "Users/user1".AsSpan(), buffer, out nChars);
if (flag)
Console.WriteLine($"Wrote {nChars} characters: '{buffer.Slice(0, nChars).ToString()}'");
else
Console.WriteLine("Concatenation operation failed.");
}
}
TryJoin(ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>, Span<Char>, Int32)
Attempts to concatenate three path components to a single preallocated character span, and returns a value that indicates whether the operation succeeded.
public:
static bool TryJoin(ReadOnlySpan<char> path1, ReadOnlySpan<char> path2, ReadOnlySpan<char> path3, Span<char> destination, [Runtime::InteropServices::Out] int % charsWritten);
public static bool TryJoin(ReadOnlySpan<char> path1, ReadOnlySpan<char> path2, ReadOnlySpan<char> path3, Span<char> destination, out int charsWritten);
static member TryJoin : ReadOnlySpan<char> * ReadOnlySpan<char> * ReadOnlySpan<char> * Span<char> * int -> bool
Public Shared Function TryJoin (path1 As ReadOnlySpan(Of Char), path2 As ReadOnlySpan(Of Char), path3 As ReadOnlySpan(Of Char), destination As Span(Of Char), ByRef charsWritten As Integer) As Boolean
Parameters
A character span that contains the second path to join.
A character span to hold the concatenated path.
When the method returns, a value that indicates the number of characters written to the destination
.
true
if the concatenation operation is successful; otherwise, false
.
destination
must be large enough to hold the concatenated path. You can then retrieve the concatenated path by calling the Span<T>.Slice method, as the example illustrates.
Attempts to concatenate two path components to a single preallocated character span, and returns a value that indicates whether the operation succeeded.
public:
static bool TryJoin(ReadOnlySpan<char> path1, ReadOnlySpan<char> path2, Span<char> destination, [Runtime::InteropServices::Out] int % charsWritten);
public static bool TryJoin(ReadOnlySpan<char> path1, ReadOnlySpan<char> path2, Span<char> destination, out int charsWritten);
static member TryJoin : ReadOnlySpan<char> * ReadOnlySpan<char> * Span<char> * int -> bool
Public Shared Function TryJoin (path1 As ReadOnlySpan(Of Char), path2 As ReadOnlySpan(Of Char), destination As Span(Of Char), ByRef charsWritten As Integer) As Boolean
Parameters
A character span that contains the second path to join.
A character span to hold the concatenated path.
When the method returns, a value that indicates the number of characters written to the destination
.
true
if the concatenation operation is successful; otherwise, false
.
destination
must be large enough to hold the concatenated path. You can then retrieve the concatenated path by calling the Span<T>.Slice method, as the example illustrates.
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide. In this articleWas this page helpful?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4