What does a "!" exclamation before a string inside an if in C#


Hello, I have a doubt regarding some "snippets" of a program that I'm using to "study", the question is, what is the meaning of "!" inside an if before a string, I saw some threads on the site explaining it, but I don't understand how it works in the program I have…

if (Connect._state == HostStatus.ONLINEALERT && !string.IsNullOrEmpty(Connect._message))

The code above is one of the "snippets" that I don't understand, thanks in advance to anyone who helps me…


In general the "!" is the logical "not", that is, a negation, I believe it is the same in C# as quoted here . This snippet is probably negating string.IsNullOrEmpty(Connect._message) .

Scroll to Top