-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Context: https://github.com/dotnet/corefx/issues/33602 and https://github.com/dotnet/corefx/blob/467d45e3950e8daeda9373396da8061f5b8b3787/src/System.Runtime/ref/System.Runtime.cs#L2330-L2331
We obsoleted (as warning) the String.Copy
method in .NET Core 3 and created the fwlink https://go.microsoft.com/fwlink/?linkid=2084035 for inclusion in the obsolete message. Current the fwlink points back to the original GitHub issue, but we should update the String.Copy
docs to mention alternatives and redirect the fwlink to the official documentation.
Ideally we'd want to say something like the below, with examples of proper usage.
-
You probably didn't ever need to call this method at all, and you can just use the original
string
instance sincestring
instances are immutable. -
If you need to create a mutable buffer with the same contents as the original string, use
string.ToCharArray()
or theStringBuilder(string)
ctor. -
If you need to create a mutable copy of the string for interop purposes, use the method
Marshal.StringToHGlobalUni(string)
. Remember to free the unmanaged memory when you're done.
There may be other scenarios but I can't think of them offhand.