错误:'流':成员名称不能与其封闭类型相同

时间:2015-09-21 08:31:08

标签: c#

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 

namespace CofBalu { 
class StrongNo { 
static int Factorial(int rem) { 
    if (rem == 1) return 1;
     else return Factorial(rem - 1) * rem; } 

static int StrongNo(int n) { 
     int rem=0,Strong=0; 
     while (n > 0) { 
     Strong = Strong + Factorial(rem = n % 10);
     n = n / 10; 
     } 
return Strong; 
} 

static void Main() { 
   Console.Write("Enter a no: "); 
   int n = int.Parse(Console.ReadLine()); 
   if (StrongNo(n) == n) Console.Write("Yes, "+n+" is a STRONG NO."); 
     else Console.Write("No, " + n + " is not a STRONG NO."); 
   Console.ReadLine(); 
} 
} 
}

1 个答案:

答案 0 :(得分:0)

您的方法static int StrongNo(int n)与类名具有相同的名称。名称为类的名称的方法名称称为构造函数。构造函数没有返回类型。

所以你可以试着像这样重命名你的函数:

static int StrongNumber(int n)