Huma Ali Huma Ali - 3 months ago 9
C# Question

Replace string of object

I want to manipulate value of my object i.e it currently contains string

office
, I want to make it
home
. How ca I do this? As Replace doesn't change the actual string what other alternative do I have?

createCustomerResponse.createCustomerResponse.serviceContextType.status.Message = "You have qualified for: office"


I want to make it

createCustomerResponse.createCustomerResponse.serviceContextType.status.Message = "You have qualified for: home"

Answer

While Replace indeed doesn't change the actual string, you can just assign back replaced value:

createCustomerResponse.createCustomerResponse.serviceContextType.status.Message = 
   createCustomerResponse.createCustomerResponse.serviceContextType.status.Message
      .Replace("office", "home");