无法找到DataTable命名空间

时间:2017-02-13 18:47:17

标签: c# asp.net datatable monodevelop

我在C#ASPX中工作,我正在尝试创建一个数据表,以便我可以使用Datatable.compute()。我上了课,但我打算改变它的大部分。我已多次尝试导入并制作数据表,但我的代码拒绝工作。我到处寻找,我不知道为什么这不起作用。

代码:

using System;
using System.Collections;
using System.Data.Datatable;

namespace Krypton
{

    public partial class Default : System.Web.UI.Page
    {
        DataTable dt = new DataTable();
        Random rand = new Random();

        int[] cards = new int[6];
        ArrayList openP = new ArrayList();
        ArrayList closeP = new ArrayList();
        ArrayList pairList = new ArrayList();
        ArrayList numbers = new ArrayList();
        ArrayList comands = new ArrayList();

        String answer;

        public void generateCards(object sender, EventArgs args)
        {
            for (int i = 0; i < cards.Length; i++)
            {
                cards[i] = (1 + rand.Next(24));
            }
            card1.Text = cards[0].ToString();
            card2.Text = cards[1].ToString();
            card3.Text = cards[2].ToString();
            card4.Text = cards[3].ToString();
            card5.Text = cards[4].ToString();
            card6.Text = cards[5].ToString();
        }

        public void checkCards(object sender, EventArgs ars)
        {
            answer = answerBox.Text;
            splitString(answer);
        }

        public void splitString(String s)
        {
            char[] c = s.ToCharArray();

            for (int i = 0; i < c.Length; i++)
            {
                if (c[i] == ')')
                {
                    closeP.Add(i);
                    Boolean end = true;
                    int j = i;
                    while (!end)
                    {
                        if (c[j] == '(')
                        {
                            openP.Add(j);
                            end = true;
                        }
                        else if (j <= 0)
                        {
                            end = true;
                        }
                        else {
                            j--;
                        }
                    }
                }
            }
            for (int i = 0; i < c.Length; i++)
            {
                char ch = c[i];
                if (ch == '+')
                    comands.Add(0);
                if (ch == '-')
                    comands.Add(1);
                if (ch == '*')
                    comands.Add(2);
                if (ch == '/')
                    comands.Add(3);
                if (ch == '^')
                    comands.Add(4);
            }
            for (int i = 0; i < c.Length; i++)
            {
                char ch = c[i];
                if (isNumber(ch)) {

                }
            }

            findPairs(openP, closeP);
            doMath(pairList);
        }

        public Boolean isNumber(char c) {
            if (c == '0' || c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9')
            {
                return true;
            }
            else{
                return false;
            }
        }

        public void findPairs(ArrayList o, ArrayList c)
        {

            if (!(o.Count == c.Count))
            {
                return;
            }
            for (int i = 0; i < o.Count; i++)
            {
                NumberPair pr = new NumberPair((int)o[i], (int)c[i]);
                pairList.Add(pr);
            }
        }

        public void doMath(ArrayList a)
        {
            ArrayList strAry = new ArrayList();
            for (int i = 0; i < a.Count; i++)
            {
                NumberPair pr = (NumberPair)a[i];
                strAry.Add(answer.Substring(pr.getStart(), pr.getEnd()));
                answerBox.Text = (String)strAry[i];
            }
        }
    }
}

错误(S):

Error when compiling

Error when I have not yet compiled

编辑:我将它从system.data.database更改为system.data。它仍然无法运作:(

New error

2 个答案:

答案 0 :(得分:1)

DataTable是System.Data命名空间中的一个类。尝试将您的使用更改为System.Data:

using System.Data;

答案 1 :(得分:1)

Agalo在给我的评论中回答了这个问题,非常感谢你。

您只需将System.Data添加到引用中:

Here is where to find it.