c# - What is Use of unassigned local variable error? -
this question has answer here:
int num1 , num2; bool equel ; equel =((num1 % 10 == num2 % 10 || num1 % 10 == num2 / 10) && (num1 / 10 == num2 / 10 || num1 / 10 == num2 % 10)); console.writeline("enter 2 numbers"); console.writeline("enter first 2 digir number"); num1 = int.parse(console.readline()); console.writeline("enter secound digit numbers"); num2=int.parse(console.readline()); if(equel) console.writeline("the digits of 2 numbers equels"); else console.writeline("the digits of 2 numbers not equels");
error 1 use of unassigned local variable 'num1' d:\project visual studios\consoleapplication6\consoleapplication6\program.cs 15 29 consoleapplication6
you're using 'num1' calculate 'equel' without assigning value it. move
equel =((num1 % 10 == num2 % 10 || num1 % 10 == num2 / 10) && (num1 / 10 == num2 / 10 || num1 / 10 == num2 % 10));
to after you've finished reading values num1 , num2
Comments
Post a Comment