Replace characters in string with values

后端 未结 3 624
孤城傲影
孤城傲影 2020-12-22 11:56

I have a string which is a paragraph written on the aspx side. It goes like this:

The new student, {student_name} has the following grades -
Mat

3条回答
  •  不思量自难忘°
    2020-12-22 12:06

    Dim myString As String = "{student_name}"
    
    myString = myString.Replace("{student_name}","Joe Smith")
    

    ...Remember to always assign the string you are attempting to replace values in to the original string.

    myString.Replace("value","newvalue")

    ...will not replace your original strings values -- it must be explicitly assigned. e.g.

    myString = myString.Replace("value","newvalue")
    

提交回复
热议问题