2017-02-13 98 views
-1

我正在C#ASPX中工作,並且我正在嘗試創建一個數據表以便使用Datatable.compute()。我有一堂課,但我正計劃改變它的大部分。我已經多次嘗試導入並創建數據表,但我的代碼拒絕工作。我到處尋找,我不知道爲什麼這不起作用。無法找到DataTable名稱空間

代碼:

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

+1

'Xamarin'?你是不是指「單聲道」? – SushiHangover

+0

@SushiHangover是的,我會改變我的標籤,但程序已經融合。 – Darokrithia

+1

您是否在項目中添加了對Assembly'System.Data.dll'的引用。在解決方案資源管理器中的** References **節點下檢查。 – Agalo

回答

0

的AgAlO在回答了這個我的意見,所以非常感謝你

您只需System.Data添加到您參考:

Here is where to find it.

1

數據表是System.Data命名空間中的類嘗試使用你的改變只是System.Data:

using System.Data; 
+0

它仍然無法正常工作。我會更新我的問題 – Darokrithia

相關問題