Is it possible to have the contain function find if the string contains 2 words or more? This is what I'm trying to do:
string d = "You hit someone for 50 damage";
string a = "damage";
string b = "someone";
string c = "you";
if(d.Contains(b + a))
{
Console.WriteLine(" " + d);
Console.ReadLine();
}
When I run this, the console window just shuts down really fast without showing anything.
And another question: if I for one want to add how much damage is done, what would be the easiest way to get that number and get it into a TryParse
?
if(d.Contains(a) && d.Contains(b))
– Inaudibleb
anda
, so you're essentially writingif(d.Contains("someonedamage"))
which won't work. Your if-statement fails and therefore will not hitConsole.ReadLine()
. Seriously, this is extremely basic debugging, please learn how to step through your code. – Vaquero