Search code examples
vb.netstringwindows-phone-7

replacing the last character in a string


I have another question again about visual basic, the language I am using now in developing apps for windows phone 7.5. My question is how can I replace the last character in a string? Example I have the string "clyde", now I want to replace the last character 'e' with 'o', but how can I do that? Any help would be so appreciated.


Solution

  • String str = "clyde";
    str = str.Substring(0, str.Length - 1) + 'o';
    

    Tried some online VB converter

    Dim str As String = "clyde"
    str = str.Substring(0, str.Length - 1) & "o"C