I have this piece of code:
description="EUR CMS Swap";
description_token=description.Split(" ".ToCharArray());
bool check;
if(description_token.Contains("EUR CMS"))
check=true;
But check is always false, even though
description_token[0]="EUR"
description_token[1]="CMS"
What am I doing wrong? Is there an alternative method?
The source value you have gets split into the array by spaces, so you should have three objects in your array
(EUR, CMS and Swap)
So you should rewrite your check to be
if(description_token.Contains("EUR") || description_token.Contains("CMS"))
(if it is enough if just one of the values is inside that array)
or
if(description_token.Contains("EUR") && description_token.Contains("CMS"))
(if both values HAVE to be inside that array)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With