I was trying to write some try catch
for Convert.FromBase64String()
and I found out that it already has TryFromBase64String()
method. But it needs 3 arguments:
public static bool TryFromBase64String(string s, Span<byte> bytes, out int bytesWritten);
So how can I use Span<byte> bytes
there?
I only found this in docs, but without proper description. Maybe this is too obvious.
https://learn.microsoft.com/en-us/dotnet/api/system.convert.tryfrombase64string?view=netcore-2.1
Thank to @Damien_The_Unbeliever and THIS article I found out more about Span
. So...
Span is used for saving memory and don't call GC so much. It can store arrays or portion of array, but I still can't figure out how to use it in that method.