为什么提示数组a不包含Max方法,找不到错误原因
using System;using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace 类方法的数组性参数
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Maxer m = new Maxer();
int[] a = new int[] { 4, 7, 5, 6, 8, 9 };
int max = a.Max(a);
// int max=a.Maxp(5,4,6,2,8,99,4,66,3,5);
this.textBox1.Text = max.ToString();
// this.textBox2.Text = maxp.ToString();
}
class Maxer
{
public int Max(int[] numbers)
{
int k = 0;
for (int i = 0; i < numbers.Length; i++)
{
if (numbers[k] < numbers[i])
k = i;
}
return numbers[k];
}
}
/* public int Maxp(int[] numbers)
{
int k = 0;
for (int i = 0; i < numbers.Length; i++)
{
if (numbers[k] < numbers[i])
k = i;
}
return numbers[k];
}*/
}
}
}
}