# C#这样写方法，对吗？

0
[已解决问题] 解决于 2017-04-17 20:55

`private` `void` `Method1()`

`        ``{`
`           ``string``[]A={ ``"1"``, ``"2"``, ``"3"``, ``"4"``, ``"5"` `};`
`            ``for` `(``int` `i = 0; i < A.Length; i++)`
`            ``{`
`              ``string` `str1=A[i];`
`              ``Method2();`
`            ``}`
`        ``}`
` ``private` `void` `Method2()`
`        ``{`
`           ``string``[] B = { ``"3"``, ``"5"``, ``"7"``, ``"8"``, ``"9"` `};`
`            ``for` `(``int` `i = 0; i < B.Length; i++)`
`            ``{`
`              ``string` `str2=B[i];`
`            ``}`
`        ``}`

| 菜鸟二级 | 园豆：278

1

`private` `void` `Method1()`

`        ``{`
`           ``string``[]A={ ``"1"``, ``"2"``, ``"3"``, ``"4"``, ``"5"` `};`
`            ``for` `(``int` `i = 0; i < A.Length; i++)`
`            ``{`
`              ``string` `str1=A[i];`
`              ``Method2(str1);`
`            ``}`
`        ``}`
`private` `void` `Method2( str1)`
`        ``{`
`           ``string``[] B = { ``"3"``, ``"5"``, ``"7"``, ``"8"``, ``"9"` `};`
`            ``for` `(``int` `i = 0; i < B.Length; i++)`
`            ``{`
`              ``string` `str2=B[i];`
if(str1  == str2) MessageBox.Show("pass");
`            ``}`
`        ``}`

codingHeart | 小虾三级 |园豆：1511 | 2017-04-17 16:23

| 园豆：278 (菜鸟二级) | 2017-04-17 20:54

0
```        private void Method1()
{
string[] A = { "1", "2", "3", "4", "5" };
for (int i = 0; i < A.Length; i++)
{
if (i == 0)
{
Method2(A[i]);
}
}
}
private void Method2(string first)
{
string[] B = { "3", "5", "7", "8", "9" };
for (int i = 0; i < B.Length; i++)
{
if (first == B[i]) {
MessageBox.Show("pass");
}
}
}```

0

您需要登录以后才能回答，未注册用户请先注册