-1

I have read all similar questions and acted accordingly. But still can't figure out what's wrong with my code.

This is my code, super simple. (I know this isn't valid XML. It's just for the example).

string replacement = "TimeSheetsReplaced";
string word = "TimeSheets";
string result = "<?xml version=\"1.0\" encoding=\"utf-16\"?><DisplayName>Timesheets</DisplayName>"; 
result = result.Replace("<DisplayName>" + word + "</DisplayName>", "<DisplayName>" + replacement + "</DisplayName>");

The result string remains unplaced. What am I doing wrong??

RajeshKdev
  • 6,365
  • 6
  • 58
  • 80
Uri Klar
  • 3,800
  • 3
  • 37
  • 75

3 Answers3

4

TimeSheets != Timesheets

Casing does not match

fguchelaar
  • 4,779
  • 23
  • 36
2

It's because your string contains Timesheets, but you're lokoing for TimeSheets (with a capital S).

Cristian Lupascu
  • 39,078
  • 16
  • 100
  • 137
0

In your word TimeSheets has big S, in string small s

Maxim Zabolotskikh
  • 3,091
  • 20
  • 21