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

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -