I use string.Create method to create a new string like this:
var rawStr = "raw str";
var newStr = string.Create(rawStr.Length, rawStr,
(chars, str) =>
{
chars = str.ToCharArray();
});
but, the result newStr just an empty char array.
I saw an answer here, and modify my code:
var rawStr = "raw str";
var newStr = string.Create(rawStr.Length, rawStr.ToCharArray(),
(chars, str) =>
{
//chars = str.ToCharArray();
for (int i = 0; i < chars.Length; i++)
{
chars[i] = str[i];
}
});
Then, newStr's value is raw str, this is why?