Newbie class question

  • Thread starter Thread starter Lou
  • Start date Start date
L

Lou

I come from VB so..
I created a class named Channel, to create an instance of that class,
On a form button click i add the following code:

private void button1_Click(object sender, System.EventArgs e)

{

Channel myChannel=New Channel();


}

but I get a build error there, says ";expected"
with Channel() underlined as the culprit but I clearly have the
semi-colon????

All I want to do is create a class and then instantiate it?????
should be easy. In VB its
Dim myChannel As New Channel

-Louie
 
Do Clannel and the class you are instantiating it reside in the same
namespace?

If not, add a using statement at the top of the file of the calling class

using Mynamespace;


HTH
Brian W
 
Found the problem , seems the keyword "new' neewds to be lower case.
Is there an equivalent VB Option Explict to force keywords into proper case?
 
Hi Lou!

I come from VB so..
Channel myChannel=New Channel();

VB is not Case Sensitive. C# is!

Channel myChannel=new Channel();

(new instead of New!!!)

Maybe you should use an Editor with Code Highlighting, so you see these
kind of errors!

With kind regards,

Konrad
 
Hi Lou!

Lou said:
Found the problem , seems the keyword "new' neewds to be lower case.
Is there an equivalent VB Option Explict to force keywords into proper
case?

No - C# is Case Sensitiv. So maybe you should use an editor, that has
code highlighting. Then you can see, if you wrote the keywords the
correct way. (Or simply write all keywords small. Only use upper case
letters in Names!)

I hope that helps for the future.

With kind regards,

Konrad
 
Lou said:
I come from VB so..
I created a class named Channel, to create an instance of that class,
On a form button click i add the following code:

private void button1_Click(object sender, System.EventArgs e)

{

Channel myChannel=New Channel();


}

but I get a build error there, says ";expected"
with Channel() underlined as the culprit but I clearly have the
semi-colon????

All I want to do is create a class and then instantiate it?????
should be easy. In VB its
Dim myChannel As New Channel

-Louie

In addition to Brian's comments, you have a syntax error.

C# is case-sensitive, which means "New" and "new" are not the same thing.
The keyword you want is "new" with a lower-case "n".

Good luck,
Ryan LaNeve
MCSD.NET
 
thanks all.....
-lou

Ryan LaNeve said:
In addition to Brian's comments, you have a syntax error.

C# is case-sensitive, which means "New" and "new" are not the same thing.
The keyword you want is "new" with a lower-case "n".

Good luck,
Ryan LaNeve
MCSD.NET
 
Back
Top