What is the !=?

Asked

Viewed 194 times

-1

What is the purpose of the != in C# and how can I use it properly? I visualized an example in a repeat structure with for, however I did not understand very well the function of it.

int soma = 0;
for (int i = 1; i <= 100; i++)
{
    if (i % 3 != 0)
    {
        soma += i;
    }
}
  • 1

    != would be: not equal to, different from, etc ... basically the opposite of ==

  • 2

    It is the binary inequality operator. Suggested: https://msdn.microsoft.com/en-us/library/czs2584d.aspx

1 answer

1


In c# != is a relational operator meaning "different from".

Other relational operators are ==, <, >, <=, >=, meaning equal, less than, greater than, less than, less than or equal and greater or equal respectively.

They are used to make conditions with commands if, while, among others.

Some examples can be found here: https://www.tutorialspoint.com/csharp/csharp_relational_operators.htm

Browser other questions tagged

You are not signed in. Login or sign up in order to post.