i have a String Array which comes from a splitted String
string[] newName= oldName.Split('\\');
newName.Last().Replace(newName.Last(), handover);
Why doesnt this replaces my last element in the Array?
last() comes from using linq
regards
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Calling
string.Replacedoesn’t alter the existing string – strings are immutable.Instead, it returns a new string, with the appropriate replacements. However, you’re not using the return value, so it’s basically a no-op.
You need to change the array element itself to refer to a different string. Something like this: