" 语法错误,错误的数组声明符。若要声明托管数组,秩说明符应位于变量标识符之前"是什么意思(50分)

  • 主题发起人 yinnifeiyang
  • 开始时间
Y

yinnifeiyang

Unregistered / Unconfirmed
GUEST, unregistred user!
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace game
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.RichTextBox richTextBox1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(120, 40);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(152, 16);
this.label1.TabIndex = 0;
this.label1.Text = "label1";
//
// button1
//
this.button1.Location = new System.Drawing.Point(256, 88);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(72, 24);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(120, 88);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 2;
this.textBox1.Text = "textBox1";
//
// richTextBox1
//
this.richTextBox1.Location = new System.Drawing.Point(120, 136);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(184, 80);
this.richTextBox1.TabIndex = 3;
this.richTextBox1.Text = "";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(448, 273);
this.Controls.Add(this.richTextBox1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void textBox2_TextChanged(object sender, System.EventArgs e)
{
if(textBox1.Text.Length !=0) //假如输入文本框长度不为零,那么就把确定按建设为能使
  {
   button1.Enabled=true;
  };
 else
//if(textBox1.Text.Length==0) //假如输入文本框长度为零,就把确定按建设为不能使。
  {
   button1.Enabled=false;
  }
}
private void Form1_Load(object sender, System.EventArgs e)
{
this.button1.Enabled=false;
}
private void button1_Click(object sender, System.EventArgs e)
{
string text=textBox1.Text;
// 本段代码是游戏者在按确定按键时引发的事件
  string output1;
// 本段代码使用了两个方法,分别将谁,在哪,干什么
  output1=text;
// 写入了output.Text框,并显示出来。
  output1+=where();
// 同时将确定键再设为不可用。
  output1+=dowhat();
  textBox1.Text=output1;
  textBox1.Text="";
  button1.Enabled=false;
}
private string where()
{
 string[] where = new string[10];
// 开一个数组,存上地点
 where[0]="在家里";
 where[1]="在学校";
 where[2]="在马路上";
 where[3]="在公共厕所";
 where[4]="在树上";
 where[5]="在澡盆里";
 where[6]="在飞机上";
 where[7]="在食堂";
 where[8]="在夜总会";
 where[9]="在航天飞机上";
 Thread.Sleep(2);
// 利用随机数随机产生0-9的一个值
 Random y = new Random();
 int result = (int)y.Next()%10;
 return where[result];
// 将结果返回
}
private stringdo
what()
{
 string[]do
what=new[10];
//开一个数组,存上干什么
 dowhat[0]="吃面条";
 dowhat[1]="洗澡";
 dowhat[2]="睡觉";
 dowhat[3]="踢足球";
 dowhat[4]="练跆拳道";
 dowhat[5]="跳芭蕾";
 dowhat[6]="写作业";
 dowhat[7]="跳脱衣舞";
 dowhat[8]="玩过家家";
 dowhat[9]="吃烤鸭";
 Thread.Sleep(1);
 Random y = new Random();
// 利用随机数随机产生0-9的一个值
 int result = (int)y.Next()%10;
 returndo
what[result];
// 将结果返回
}

}
}

 
用ArrayList试试。
 
c#没玩过
 
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;
//[red]這裡有修改[:)][/red]
namespace game
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.RichTextBox richTextBox1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(120, 40);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(152, 16);
this.label1.TabIndex = 0;
this.label1.Text = "label1";
//
// button1
//
this.button1.Location = new System.Drawing.Point(256, 88);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(72, 24);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(120, 88);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 2;
this.textBox1.Text = "textBox1";
//
// richTextBox1
//
this.richTextBox1.Location = new System.Drawing.Point(120, 136);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(184, 80);
this.richTextBox1.TabIndex = 3;
this.richTextBox1.Text = "";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(448, 273);
this.Controls.Add(this.richTextBox1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void textBox2_TextChanged(object sender, System.EventArgs e)
{
if(textBox1.Text.Length !=0) //假如输入文本框长度不为零,那么就把确定按建设为能使
  {
  this.button1.Enabled=true;
  }
else
//if(textBox1.Text.Length==0) //假如输入文本框长度为零,就把确定按建设为不能使。
   button1.Enabled=false;
}
private void Form1_Load(object sender, System.EventArgs e)
{
this.button1.Enabled=false;
}
private void button1_Click(object sender, System.EventArgs e)
{
string text=textBox1.Text;
// 本段代码是游戏者在按确定按键时引发的事件
  string output1;
// 本段代码使用了两个方法,分别将谁,在哪,干什么
  output1=text;
// 写入了output.Text框,并显示出来。
  output1+=where();
// 同时将确定键再设为不可用。
  output1+=dowhat();
  textBox1.Text=output1;
  textBox1.Text="";
  button1.Enabled=false;
}
private string where()
{
  string[] where = new string[10];
// 开一个数组,存上地点
  where[0]="在家里";
  where[1]="在学校";
  where[2]="在马路上";
  where[3]="在公共厕所";
  where[4]="在树上";
  where[5]="在澡盆里";
  where[6]="在飞机上";
  where[7]="在食堂";
  where[8]="在夜总会";
  where[9]="在航天飞机上";
  Thread.Sleep(2);
// 利用随机数随机产生0-9的一个值
  Random y = new Random();
  int result = (int)y.Next()%10;
  return where[result];
// 将结果返回
}
private stringdo
what()
{
  string[]do
what=new string [10];
//开一个数组,存上干什么,[green]这里也有修改。[/green]
  dowhat[0]="吃面条";
  dowhat[1]="洗澡";
  dowhat[2]="睡觉";
  dowhat[3]="踢足球";
  dowhat[4]="练跆拳道";
  dowhat[5]="跳芭蕾";
  dowhat[6]="写作业";
  dowhat[7]="跳脱衣舞";
  dowhat[8]="玩过家家";
  dowhat[9]="吃烤鸭";
  Thread.Sleep(1);
  Random y = new Random();
// 利用随机数随机产生0-9的一个值
  int result = (int)y.Next()%10;
  returndo
what[result];
// 将结果返回
}

}
}
 
多人接受答案了。
 
顶部