[Solved] How to replace the string inside { } with new value [closed]


If you could use a different string for your template, something like this would work:

string formattedText = string.Format(
    "{0} has deviated from GeoFence at {1} in {2}", 
    vehicleno, 
    dt.ToString("MM/dd/yyyy"), 
    location);

Alternatively, you could chain together Replace() calls using your template:

string formattedText = s.Replace("{Vehicle No}", vehicleno).Replace(...).Replace(...);

1

solved How to replace the string inside { } with new value [closed]