IOT Virtual Conference - Register now to book your ticket and get updates
x
CONGRATULATIONS! C# Corner Q1, 2021 MVPs Announced
Why Join
Become a member
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
C# Corner Home
Technologies
Monthly Leaders
ASK A QUESTION
Forumguidelines
Ant 6729
1.9k
83
988
Cycle my question
Jun 29 2019 5:10 PM
Hello I need to ask user until he loads write answer
using
System;
namespace
_3_??
{
public
delegate
int
BinaryOp(
int
x,
int
y);
public
class
SimpleMath
{
public
static
int
Add(
int
x,
int
y)
{
return
x + y; }
}
class
Program
{
static
void
MyMethod()
{
int
userresult;
Console.WriteLine(
"Insert sum of x and y"
);
userresult = Convert.ToInt16(Console.ReadLine());
//return {int userresult};
}
static
void
Main(
string
[] args)
{
BinaryOp b =
new
BinaryOp(SimpleMath.Add);
string
useranswer;
int
userresult;
int
pcresult;
Console.WriteLine(
"Insert first number"
);
int
x = (Convert.ToInt16(Console.ReadLine()));
Console.WriteLine(
"Insert second number"
);
int
y = (Convert.ToInt16(Console.ReadLine()));
Console.WriteLine(
"Insert sum of x and y"
);
userresult = (Convert.ToInt16(Console.ReadLine()));
pcresult = b(x, y);
if
(userresult != pcresult)
{
Console.WriteLine(
"Something wrong with your calculations, man..."
+
"\n"
+
"Would you like to continue...? (y/n) : "
);
useranswer = Convert.ToString(Console.ReadLine());
switch
(useranswer)
{
case
"y"
:
MyMethod();
break
;
case
"n"
:
Console.WriteLine(
"If I were you, I’d better practice over....You never know..."
);
break
;
default
:
break
;
}
}
else
{
Console.WriteLine(
"Right"
);
}
}
}
}
Could you help me?
Reply
Answers (
2
)
Error : Incorrect syntax near the keyword 'Table'." ?
How to Show Image in new Tab on gridview image button click?