Click here to Skip to main content
16,005,734 members
Home / Discussions / C#
   

C#

 
Questionlist view Pin
TAREQ F ABUZUHRI14-Aug-06 7:26
TAREQ F ABUZUHRI14-Aug-06 7:26 
QuestionEnum within a button click event on a form - why compile error [modified] Pin
LuluSailor14-Aug-06 6:42
LuluSailor14-Aug-06 6:42 
AnswerRe: Enum within a button click event on a form - why compile error Pin
Andrew Rissing14-Aug-06 7:00
Andrew Rissing14-Aug-06 7:00 
GeneralRe: Enum within a button click event on a form - why compile error Pin
LuluSailor14-Aug-06 7:11
LuluSailor14-Aug-06 7:11 
GeneralRe: Enum within a button click event on a form - why compile error Pin
Rob Graham14-Aug-06 7:50
Rob Graham14-Aug-06 7:50 
GeneralRe: Enum within a button click event on a form - why compile error Pin
LuluSailor14-Aug-06 9:16
LuluSailor14-Aug-06 9:16 
GeneralRe: Enum within a button click event on a form - why compile error Pin
Dave Kreskowiak14-Aug-06 10:36
mveDave Kreskowiak14-Aug-06 10:36 
GeneralRe: Enum within a button click event on a form - why compile error Pin
LuluSailor14-Aug-06 11:42
LuluSailor14-Aug-06 11:42 
:-DAh makes sense now! Thank-you so much Dave and others too.


Just as a final blessing/followup. I thought I would try to show how classes cannot be defined within a method.

The example below does not compile - because you cannot define a class within a method ( you get the compile error: "} expected" on the line after the Main method) . And so the same problem would occur with the Enum - because you defining a class.


namespace ConsoleApplication2
{

class Program
{
static void Main(string[] args)
{
class temps
{
public int cold;
public int fp;

public temps()
{
cold = 0;
fp = 32;
}
}
temps xTemps = new temps();

System.Console.WriteLine("freezing is {0}", xTemps.fp);
}
}
}


If you move the definition of the class where it can legally be defined (in namespace or within another class - in this case I moved it to the namespace)... then all works well.


namespace ConsoleApplication2
{
class temps
{
public int cold;
public int fp;

public temps()
{
cold = 0;
fp = 32;
}
}
class Program
{
static void Main(string[] args)
{

temps xTemps = new temps();

System.Console.WriteLine("freezing is {0}", xTemps.fp);
}
}
}



Questionsystem properties Pin
Harikrk14-Aug-06 6:40
Harikrk14-Aug-06 6:40 
AnswerRe: system properties Pin
Rob Graham14-Aug-06 7:59
Rob Graham14-Aug-06 7:59 
Questioncreating OCX Pin
Harikrk14-Aug-06 5:27
Harikrk14-Aug-06 5:27 
AnswerRe: creating OCX Pin
Rob Graham14-Aug-06 5:42
Rob Graham14-Aug-06 5:42 
GeneralRe: creating OCX Pin
Harikrk14-Aug-06 5:55
Harikrk14-Aug-06 5:55 
GeneralRe: creating OCX Pin
Rob Graham14-Aug-06 6:17
Rob Graham14-Aug-06 6:17 
GeneralRe: creating OCX Pin
Harikrk14-Aug-06 6:22
Harikrk14-Aug-06 6:22 
GeneralRe: creating OCX Pin
Rob Graham14-Aug-06 7:32
Rob Graham14-Aug-06 7:32 
GeneralRe: creating OCX Pin
Judah Gabriel Himango14-Aug-06 6:22
sponsorJudah Gabriel Himango14-Aug-06 6:22 
GeneralRe: creating OCX Pin
Harikrk14-Aug-06 6:24
Harikrk14-Aug-06 6:24 
AnswerRe: creating OCX Pin
Judah Gabriel Himango14-Aug-06 5:43
sponsorJudah Gabriel Himango14-Aug-06 5:43 
QuestionHow Can I get Keyboard Layout? Pin
3DoorsDown14-Aug-06 4:54
3DoorsDown14-Aug-06 4:54 
AnswerRe: How Can I get Keyboard Layout? Pin
Judah Gabriel Himango14-Aug-06 5:44
sponsorJudah Gabriel Himango14-Aug-06 5:44 
GeneralRe: How Can I get Keyboard Layout? Pin
3DoorsDown18-Aug-06 9:23
3DoorsDown18-Aug-06 9:23 
Questionhow to draw on control Pin
mortadacode14-Aug-06 4:49
mortadacode14-Aug-06 4:49 
AnswerRe: how to draw on control Pin
Super Lloyd14-Aug-06 5:05
Super Lloyd14-Aug-06 5:05 
QuestionITemplate Pin
erikkl200014-Aug-06 4:26
erikkl200014-Aug-06 4:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.