using System;
namespace Let_sTalk
{
class Program
{
static void Main(string[] args)
{
Console.Write("<-:");
string q = Console.ReadLine();
string w = Console.ReadLine();
string e = Console.ReadLine();
if (q, w, e == "/")
{
Console.WriteLine("over");
}
}
}
}
Asked
Active
Viewed 34 times
-5

David L
- 32,885
- 8
- 62
- 93
-
4This is invalid C# syntax. You cannot combine multiple evaluations into a single equality operator like this. You need to explicitly write out each operation. I suggest reading through C# tutorials and language guides. – David L Jan 20 '22 at 19:35
-
1Your title is nearly incomprehensible ("marking" strings???). the body of the post offers no clarification or explanation nor does it ask a question. Four of the five tags selected do not apply. Please visit the [help] ats soon as you can and study [ask] – Ňɏssa Pøngjǣrdenlarp Jan 20 '22 at 19:40
-
My english is low, becose i used google translate maybe translated badly – Danijel Veselinović Jan 21 '22 at 20:11
1 Answers
1
You cannot use the comma (,
) symbol to separate variables in an if statement. That's invalid C# syntax.
Also, in C# string comparison is done with the Equals
function. The ==
will still work in most cases, but there are some additional error handlings with the Equals
function.
If you want to check if at least one of the q, w, e
variables is equal to /
, then use the following code:
if (q.Equals("/") || w.Equals("/") || e.Equals("/"))
{
Console.WriteLine("over");
}
If you wish to check if all q, w, e
variables are equal to /
, then you have to replace the ||
(or operator) with &&
(and operator) like so:
if (q.Equals("/") && w.Equals("/") && e.Equals("/"))
{
Console.WriteLine("over");
}

Kostoski Stefan
- 56
- 5