Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve '...is a 'type', which is not valid in the given context'? (C#)

Tags:

The following code produces the error:

Error : 'CERas.CERAS' is a 'type', which is not valid in the given context

Why does this error occur?

using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;  namespace WinApp_WMI2 {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();         }          private void Form1_Load(object sender, EventArgs e)         {             CERas.CERAS = new CERas.CERAS();         }     } } 
like image 937
ALEXALEXIYEV Avatar asked Feb 17 '10 07:02

ALEXALEXIYEV


1 Answers

Change

private void Form1_Load(object sender, EventArgs e)      {          CERas.CERAS = new CERas.CERAS();      }  

to

private void Form1_Load(object sender, EventArgs e)      {          CERas.CERAS c = new CERas.CERAS();      }  

Or if you wish to use it later again

change it to

using System.Drawing;  using System.Linq;  using System.Text;  using System.Windows.Forms;   namespace WinApp_WMI2  {      public partial class Form1 : Form      {          CERas.CERAS m_CERAS;          public Form1()          {              InitializeComponent();          }       private void Form1_Load(object sender, EventArgs e)      {          m_CERAS = new CERas.CERAS();      }  }    } 
like image 182
Adriaan Stander Avatar answered Oct 24 '22 03:10

Adriaan Stander