今天 编写程序,遇到了 "成员名称不能与它们的封闭类型相同",代码如下:
如果有人知道,请解答!
1
using System;
2
using System.Collections.Generic;
3
using System.Text;
4
5
namespace judge
6
{
7
class Judge
8
{
9
string Judge(int a)
10
{
11
string d;
12
int c = 0;
13
for (int i = 1; i <= a; i++)
14
{
15
int b = a % i;
16
if (b == 0)
17
{
18
19
c++;
20
21
}
22
23
}
24
if (c > 2)
25
{
26
27
d = "不是素数!";
28
29
30
}
31
else
32
{
33
d = "是素数!";
34
35
}
36
37
return d;
38
39
}
40
static void Main(string[] args)
41
{
42
string x = Console.ReadLine();
43
int ni = int.Parse(x);
44
Judge newj = new Judge();
45
Console.WriteLine(newj.Judge(ni));
46
47
48
}
49
}
50
}
51
52
请高人指点!
using System;2
using System.Collections.Generic;3
using System.Text;4

5
namespace judge6
{7
class Judge8
{9
string Judge(int a)10
{11
string d;12
int c = 0;13
for (int i = 1; i <= a; i++)14
{15
int b = a % i;16
if (b == 0)17
{18
19
c++;20
21
}22
23
}24
if (c > 2)25
{26

27
d = "不是素数!";28

29

30
}31
else32
{33
d = "是素数!";34
35
}36

37
return d;38
39
}40
static void Main(string[] args)41
{42
string x = Console.ReadLine();43
int ni = int.Parse(x);44
Judge newj = new Judge();45
Console.WriteLine(newj.Judge(ni));46
47

48
}49
}50
}51

52



浙公网安备 33010602011771号