+ Start a Discussion
nelloCnelloC 

enum in an inner class

Are enum's allowed in inner classes? I'm getting a Save error: unexpected token: 'enum'

Can't find anthing that suggests they're not...

// Inner classes

class FromAddressItem {

public enum AddressType {TYPE_A, TYPE_B, TYPE_C}

public FromAddressItem (string type_In, string emailAddress_In, string displayName_In) {
AddressType = type_In;
EmailAddress = emailAddress_In;
DisplayName = displayName_In;
}

// Class properties

public string AddressType { get; private set; }

public string EmailAddress { get; private set; }

public string DisplayName { get; private set; }
}

Any ideas?

 

 

 

Message Edited by nelloC on 11-22-2009 04:35 AM
Best Answer chosen by Admin (Salesforce Developers) 
gm_sfdc_powerdegm_sfdc_powerde
Apex allows inner classes only one level deep, which means you cannot create an enum (which is like a class) in the inner class.

All Answers

gm_sfdc_powerdegm_sfdc_powerde
Apex allows inner classes only one level deep, which means you cannot create an enum (which is like a class) in the inner class.
This was selected as the best answer
nelloCnelloC

Ah okay, of course. Why didn't I think of that!

Thanks.