也許我錯過了一些完全簡單的東西,但是在我創建的任何新窗口中,我不能再使用Convert方法。我很確定我所有的使用指令都在那裏,我沒有使用擴展名。自從上次我使用它以來,我一直沒有做任何改變VS,當一切正常。Visual C#:不能在WinForms中使用Convert方法
難道這是VS 2011 Beta版的一個小問題,或者只是我的一個簡單的錯誤?
這裏是我的錯誤代碼一起顯示:
「System.Windows.Forms.Button」不包含一個定義 「ToInt32」
,並沒有擴展方法「ToInt32」接受型
「System.Windows.Forms.Button」的第一個參數可以發現
(是否缺少using指令或程序集引用?)
下面的代碼:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TempConvert
{
public partial class Form1 : Form
{
int degreesEntered;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Convert_Click(object sender, EventArgs e)
{
degreesEntered = Convert.ToInt32(Degrees.Text);
}
}
}
對我來說簡單的監督。感謝您的快速,理解,迴應。它沒有點擊(沒有雙關語意思),我用保留關鍵字命名了我的按鈕。 – Serkroth 2012-07-09 02:55:25
「轉換」不是關鍵字。這個問題可能發生在任何類中,並且本質上是命名空間的一個重點。 – 2012-07-09 04:31:14