Click here to Skip to main content
15,923,006 members
Home / Discussions / C#
   

C#

 
AnswerRe: Can an object cast itself to a derived class? Pin
chaiguy133725-Aug-08 14:50
chaiguy133725-Aug-08 14:50 
QuestionHow can I add a button here ? Pin
Mohammad Dayyan25-Aug-08 10:01
Mohammad Dayyan25-Aug-08 10:01 
AnswerRe: How can I add a button here ? Pin
DaveyM6925-Aug-08 10:19
professionalDaveyM6925-Aug-08 10:19 
AnswerRe: How can I add a button here ? Pin
Thomas Stockwell26-Aug-08 2:16
professionalThomas Stockwell26-Aug-08 2:16 
QuestionPassing array to operator overload Pin
DaveyM6925-Aug-08 9:48
professionalDaveyM6925-Aug-08 9:48 
AnswerRe: Passing array to operator overload Pin
DaveyM6925-Aug-08 10:21
professionalDaveyM6925-Aug-08 10:21 
GeneralRe: Passing array to operator overload Pin
chaiguy133725-Aug-08 14:53
chaiguy133725-Aug-08 14:53 
QuestionEnum / Cast Question Pin
Kevin Marois25-Aug-08 7:56
professionalKevin Marois25-Aug-08 7:56 
The docs for Enum says (paraphrasing) "Enumerations have an underlying type used for storage, which by default is int"

So I have:

using System;

namespace Employee_Example1
{
	public enum EmployeeType
	{
		FullTime = 0,
		PartTime = 1,
		Contract = 2,
		Other = 3
	}

	public class Employee_Base
	{
			
		public int iEmpId = 0;
		public int iEmployeeType = EmployeeType.FullTime;
		public double dSalary = 0.00;
		public string sLastName = "";
		public string sFirstName = "";
			
		public Employee_Base()
		{
		}
	}
}


So why am I getting the error "Cannot implicitly convert type 'Employee_Example1.EmployeeType' to 'int'"

I have also tried "public enum EmployeeType : int", and it still won't compile. However, this works:

public int iEmployeeType = (int)EmployeeType.FullTime;


The question is, if the enum's underlying type is int, why do I need to cast?

Everything makes sense in someone's mind

AnswerRe: Enum / Cast Question Pin
User 665825-Aug-08 8:12
User 665825-Aug-08 8:12 
AnswerRe: Enum / Cast Question Pin
TheFM23425-Aug-08 8:22
TheFM23425-Aug-08 8:22 
AnswerRe: Enum / Cast Question Pin
Mark Salsbery25-Aug-08 8:22
Mark Salsbery25-Aug-08 8:22 
AnswerRe: Enum / Cast Question Pin
DaveyM6925-Aug-08 9:03
professionalDaveyM6925-Aug-08 9:03 
QuestionRe: Enum / Cast Question Pin
chaiguy133725-Aug-08 14:55
chaiguy133725-Aug-08 14:55 
AnswerRe: Enum / Cast Question Pin
N a v a n e e t h25-Aug-08 18:13
N a v a n e e t h25-Aug-08 18:13 
AnswerRe: Enum / Cast Question Pin
DaveyM6925-Aug-08 23:10
professionalDaveyM6925-Aug-08 23:10 
GeneralRe: Enum / Cast Question Pin
chaiguy133726-Aug-08 4:42
chaiguy133726-Aug-08 4:42 
Questionhow to drag and drop control on the form? Pin
mohamad108825-Aug-08 6:56
mohamad108825-Aug-08 6:56 
QuestionHosting Pin
ellllllllie25-Aug-08 5:12
ellllllllie25-Aug-08 5:12 
AnswerRe: Hosting Pin
chaiguy133725-Aug-08 14:57
chaiguy133725-Aug-08 14:57 
QuestionHow to dail with controls at runtime? Pin
mohamad108825-Aug-08 5:07
mohamad108825-Aug-08 5:07 
AnswerRe: How to dail with controls at runtime? Pin
Dr. Emmett Brown25-Aug-08 5:32
Dr. Emmett Brown25-Aug-08 5:32 
AnswerRe: How to dail with controls at runtime? Pin
User 665825-Aug-08 5:33
User 665825-Aug-08 5:33 
QuestionSet ifelse in workflow Pin
A.firooz25-Aug-08 4:51
A.firooz25-Aug-08 4:51 
AnswerRe: Set ifelse in workflow Pin
Manas Bhardwaj25-Aug-08 5:07
professionalManas Bhardwaj25-Aug-08 5:07 
QuestionReaching sql database diagram by using smo? Pin
omegazafer25-Aug-08 3:26
omegazafer25-Aug-08 3: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.