TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
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
Forums
Monthly Leaders
Forum guidelines
Orange North
NA
2
963
I need help with my simple calculator!
Apr 21 2017 10:13 AM
I just started learning C# and i wanted to build a simple calculator but I keep getting error messages
The error message I keep getting is :
Error CS0165 Use of unassigned local variable 'result'
class
Program
{
static
void
Main(
string
[] args)
{
int
num01 = Convert.ToInt32(Console.Read());
char
method = Console.ReadKey().KeyChar;
int
num02 = Convert.ToInt32(Console.Read());
int
result;
switch
(method)
{
case
'+'
:
result = num01 + num02;
break
;
case
'-'
:
result = num01 - num02;
break
;
case
'%'
:
result = num01 % num02;
break
;
case
'*'
:
result = num01 * num02;
break
;
default
:
Console.WriteLine(
"???"
);
break
;
}
Console.WriteLine(
"The answer is "
, result);
Console.ReadKey();
}
}
Reply
Answers (
3
)
What is await Task.Delay(500) And why use
how to genarate Random string in C#