Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Общие вопросы по .NET и C# > создание массива объектов


Автор: Parison 12.5.2006, 02:19
пытаюсь создать двух мерный массив label'ов.
Код

public partial class Form1 : Form
    {
        
        public Form1()
        {
            InitializeComponent();
            
        }
        private System.Windows.Forms.Label label[];
        private void InitializeComponent();
        private void Form1_Load(object sender, EventArgs e)
        {
            int i;
            
            label = new System.Windows.Forms.Label[15, 15];
            for(i = 0; i < label.Length; i++)
            label[i] = new Label();
            for (int i=0; i<9; i++)
                {
                    this.label[i, i].Location = new System.Drawing.Point(i * 9, i * 9);
                }

        }
    }

вот в этом месте private System.Windows.Forms.Label label[]; выдаёт :
Syntax error, bad array declarator. To declare a managed array the rank specifier precedes the variable's identifier. To declare a fixed size buffer field, use the fixed keyword before the field type.    
что не так, помогите пожалуйста! smile 
 

Автор: VisualProgrammerNET 12.5.2006, 07:58
надо объявлять
Код

Label[,] MyArray = new Label[15,15]

 

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)