-1

I found this issue in asp.net core. I have two strings alpha numeric, all upper cases, and no spaces either in the middle or ends.

I am getting one string from appsettings.json and other assigning locally. When I compare those two strings, the application is showing they are not the same.

string stringFromAppSetting = Configuration.GetValue<string>("AppSettingValue");

string string_Local = "1B4D3A3C8F63DBE";
bool? areTheySame=null;
if (stringFromAppSetting == string_Local )
{
    areTheySame = true;
}
else
{
    areTheySame = false;
}

I also tried stringFromAppSetting.Equals(string_Local). It still shows they are not equal. I used notepad++ to check if they are different but I found that they are same.

Can somebody please suggest the possible cause.

FortyTwo
  • 2,414
  • 3
  • 22
  • 33
WorkInProgress
  • 393
  • 6
  • 16

1 Answers1

1

Thank you all for your response. For some reason, lot of hidden characters were present when string was received from appsettings.json file.After adding a logic to remove hidden character, it worked like a charm....

Removing hidden characters from within strings

WorkInProgress
  • 393
  • 6
  • 16