I am trying to replace all of the spaces in a string to a hyphan. EG:
Fortitude Valley will equal Fortitude-Valley.
var sub = p.GetProperty("suburb").Value.Replace(" ", "-"); is causing me problems. I have tried: var sub = p.GetProperty("suburb").Value.ToString.Replace(" ", "-"); al setting var sub = p.GetProperty("suburb").Value; then doing @var.Replace(" ","-") but not go.
String Manipulation in a Partial View Macro
Hi
I am trying to replace all of the spaces in a string to a hyphan. EG:
Fortitude Valley will equal Fortitude-Valley.
var sub = p.GetProperty("suburb").Value.Replace(" ", "-"); is causing me problems. I have tried: var sub = p.GetProperty("suburb").Value.ToString.Replace(" ", "-"); al setting var sub = p.GetProperty("suburb").Value; then doing @var.Replace(" ","-") but not go.
Any help here please?
Thanks
How about
works thanks :)
Generally it's better to use GetPropertyValue than GetProperty, e.g
One further improvement, you can ensure you are returned a string by specifying the return type, e.g
Jeavon
is working on a reply...