Maybe I am missing something entirely simple here, but in any new windows form I create, I can no longer use the Convert method. I am pretty sure all my using directives are there and I am using no extensions. I have done nothing to change VS since the last time I used it, when everything worked.
Could it be a hiccup of VS 2011 Beta or just a simple error on my part?
Here is my code along with the error displayed:
‘System.Windows.Forms.Button’ does not contain a definition for
‘ToInt32’and no extension method ‘ToInt32’ accepting a first argument of type
‘System.Windows.Forms.Button’ could be found
(are you missing a using directive or an assembly reference?)
Here’s the code:
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);
}
}
}
I believe the problem is you have a button named
Convertwhich is hiding the static class – you can try using the full namespace to reference it, or doing anint.Parse