using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Drawing;namespace tetris
{
class BlockInfo
{
private BitArray _id;
private Color _bColor
......................
}
上面这个是我创建的一个类
然后我想在新创建的类中使用这个上面这个类 class BlockInfo ,新创建的类如下:
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Drawing;
namespace tetris
{
class InfoArr
{
............
public BlockInfo this[int index] //索引器,根据下标返回一个BlockInfo
{
get
{
return (BlockInfo)info[index];
}
...........}
}
错误 1 找不到类型或命名空间名称“BlockInfo”(是否缺少 using 指令或程序集引用?) D:\vs205.net\progject\tetris\tetris\InfoArr.cs 22 16 tetris
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Drawing;namespace tetris
{
class BlockInfo
{
private BitArray _id;
private Color _bColor
......................
}
上面这个是我创建的一个类
然后我想在新创建的类中使用这个上面这个类 class BlockInfo ,新创建的类如下:
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Drawing;
namespace tetris
{
class InfoArr
{
............
public BlockInfo this[int index] //索引器,根据下标返回一个BlockInfo
{
get
{
return (BlockInfo)info[index];
}
...........}
}
错误 1 找不到类型或命名空间名称“BlockInfo”(是否缺少 using 指令或程序集引用?) D:\vs205.net\progject\tetris\tetris\InfoArr.cs 22 16 tetris
解决方案 »
- 新手之windows服务程序
- web services服务端必须发布iis吗,能否用ip直接调用web services?
- C#winform做没有窗体的程序
- 关于数据源的和dataset问题
- Grid中选择事件
- 怎样判断this.pictureBox2.Image 等不等于this.imageList1.Images[n]
- 随闷中...如何取得指定类属性的命名?
- C#编程一定要继承Form才能使用自定义消息或事件吗
- 江湖救急:webService里访问access,在vs下调试有数据,在iis里没有数据
- 问了N次的问题了,没有解决。我的分全送了!
- 通过数组的值得到相应的索引值
- 编程模拟网页登陆问题
class BlockInfo//此类用来 存放 单个砖块信息的类
{
private BitArray _id;//用来存放砖块的样式
public BitArray Id
{
get { return _id; }
set { _id = value; }
}
private Color _bcolor;//用来存放砖块的颜色 public Color BColor
{
get { return _bcolor; }
set { _bcolor = value; }
}
public BlockInfo(BitArray bArray, Color col)
{
_id = bArray;
_bcolor = col;
}
public string GetIdStr()
{
StringBuilder s = new StringBuilder();
foreach (bool b in _id)
{
s.Append(b? "1":"0");
}
return s.ToString();
}
public string GetColorStr()
{
return Convert.ToString(_bcolor.ToArgb());
} class InfoArr
{
private ArrayList info = new ArrayList();
private int _length=0;
public int Length
{
get{return _length ;}
}
public BlockInfo this[int index]
{
get
{
return (BlockInfo)info [index];
}
}
public string this[string id]
{
set
{
if (value == "")
return;
for (int i = 0; i < info.Count; i++)
{
if (((BlockInfo)info[i]).GetIdStr() == id)
{
try
{
((BlockInfo)info[i]).BColor = Color.FromArgb(Convert.ToInt32(value));//经过强制类型转换,此时的info已经变成BlockInfo的一个对象了,这是可以直接调用它的方法!
}
catch (System.FormatException)
{
MessageBox.Show("xml文档,颜色信息有无!");
}
}
}
}
}
public BitArray StrToBit(string id)
{
if (id.Length != 25)
{
throw new System.FormatException("砖块样式不合法!");
}
BitArray ba = new BitArray(25);
for (int i = 0; i < 25; i++)
{
ba[i] = (id[i] == '0') ? false : true;
}
return ba;
}
public void Add(BitArray id,Color bColor)
{
if (id.Length != 25)
{
throw new System.FormatException("砖块信息有误!");
}
info.Add(new BlockInfo (id,bColor));
_length++; }
public void Add(string id,string bColor)
{
Color temp;
if (!(bColor == ""))
{
temp = Color.FromArgb(Convert.ToInt32(bColor));//把字符型的颜色转化成整型的颜色
}
else
{
temp = Color.Empty;//颜色值 为空!
}
info.Add(new BlockInfo ((StrToBit (id)),temp ));
_length++;
} }你这是做的一个俄罗斯方块的吧,我也见过这个源码。我认为你的这个代码没为题啊,这是我的源码,程序没问题。
没道理BlockInfo用不了的
。
没看到 命名空间吗?? tetris 啥意思??知道不??不知道的看看这个:http://iask.sina.com.cn/b/11041272.html
没看到 命名空间吗?? tetris 啥意思??知道不??不知道的看看这个:http://iask.sina.com.cn/b/11041272.html