السلام عليكم
أقوم فى بعض الاحيان بتجربة بعض الاكواد البسيطة والأفكار العادية خروجا عن الملل المهم كنت اكتب كود برنامج المضروب الشهير وكتبت هذا الكود
using System;
public class FactorialTest
{
public static void Main( string[] args )
{
Console.WriteLine("Please give me No");
int x = int.Parse(Console.ReadLine());
int result = Factorial(x);
Console.WriteLine("the Fact is :" + result);
} // end method Main
// recursive declaration of method Factorial
public static int Factorial( int number )
{
// base case
if ( number <= 1 )
return 1;
// recursion step
else
return number * Factorial( number - 1 );
} // end method Factorial
} // end class FactorialTestفظهرت لى هذه الرسالة
اقتباسError Use of unassigned local variable 'x'
لماذا ظهرت :angry: ..وما الخطأ أصلا فى الكود . :blush: ..علما ان طريقة اللوب المعتادة لايظهر فيها هذا الخطأ :blink:
وشكرا
