Click here to Skip to main content
14,696,452 members
Home » Discussions » C#
   

C#

 
GeneralRe: extending an Enum with a function that returns a generic value ? Pin
Richard Deeming21-Apr-20 9:37
mveRichard Deeming21-Apr-20 9:37 
GeneralRe: extending an Enum with a function that returns a generic value ? Pin
BillWoodruff21-Apr-20 9:59
mveBillWoodruff21-Apr-20 9:59 
GeneralRe: extending an Enum with a function that returns a generic value ? Pin
Matthew Dennis21-Apr-20 10:16
sysadminMatthew Dennis21-Apr-20 10:16 
GeneralRe: extending an Enum with a function that returns a generic value ? Pin
BillWoodruff21-Apr-20 21:57
mveBillWoodruff21-Apr-20 21:57 
GeneralRe: extending an Enum with a function that returns a generic value ? Pin
Matthew Dennis22-Apr-20 5:35
sysadminMatthew Dennis22-Apr-20 5:35 
GeneralRe: extending an Enum with a function that returns a generic value ? Pin
BillWoodruff22-Apr-20 7:12
mveBillWoodruff22-Apr-20 7:12 
GeneralRe: extending an Enum with a function that returns a generic value ? Pin
BillWoodruff21-Apr-20 22:53
mveBillWoodruff21-Apr-20 22:53 
GeneralRe: extending an Enum with a function that returns a generic value ? Pin
Richard Deeming22-Apr-20 0:25
mveRichard Deeming22-Apr-20 0:25 
BillWoodruff wrote:
1. where T : struct, Enum ... fails without 'struct, and 'struct must precede 'Enum
Yes, for some odd reason an Enum constraint doesn't automatically imply a struct constraint.

As a result, it's possible to use where TEnum : class, Enum, which will compile but can never be satisfied.

But it's still better than not having the constraint. Smile | :)

BillWoodruff wrote:
2. 'default cannot be used directly ... WeekDays.Default throws an error
The default literal can be assigned to a variable of any type, or used as the default value of an optional parameter of any type.

It doesn't add a new member to the enum, so WeekDays.default won't work if the WeekDays enum doesn't already contain a default entry.

If you want to use the default value without assigning to a variable, you can use default(WeekDays) instead.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralRe: extending an Enum with a function that returns a generic value ? Pin
BillWoodruff22-Apr-20 4:01
mveBillWoodruff22-Apr-20 4:01 
AnswerRe: extending an Enum with a function that returns a generic value ? Pin
#realJSOP22-Apr-20 8:25
mva#realJSOP22-Apr-20 8:25 
GeneralRe: extending an Enum with a function that returns a generic value ? Pin
BillWoodruff22-Apr-20 8:39
mveBillWoodruff22-Apr-20 8:39 
GeneralRe: extending an Enum with a function that returns a generic value ? Pin
#realJSOP22-Apr-20 8:47
mva#realJSOP22-Apr-20 8:47 
GeneralRe: extending an Enum with a function that returns a generic value ? Pin
BillWoodruff22-Apr-20 21:31
mveBillWoodruff22-Apr-20 21:31 
GeneralRe: extending an Enum with a function that returns a generic value ? Pin
#realJSOP23-Apr-20 1:58
mva#realJSOP23-Apr-20 1:58 
GeneralRe: extending an Enum with a function that returns a generic value ? Pin
BillWoodruff23-Apr-20 6:25
mveBillWoodruff23-Apr-20 6:25 
QuestionSas.dll Pin
Member 1480415820-Apr-20 5:26
MemberMember 1480415820-Apr-20 5:26 
AnswerRe: Sas.dll Pin
Richard Andrew x6420-Apr-20 5:49
professionalRichard Andrew x6420-Apr-20 5:49 
GeneralRe: Sas.dll Pin
OriginalGriff20-Apr-20 5:51
mveOriginalGriff20-Apr-20 5:51 
AnswerRe: Sas.dll Pin
OriginalGriff20-Apr-20 5:50
mveOriginalGriff20-Apr-20 5:50 
QuestionAccess WebApi remotely - C'mon guys I don't believe no one has a clue ! any hint will do Pin
pkfox20-Apr-20 4:21
professionalpkfox20-Apr-20 4:21 
AnswerRe: Access WebApi remotely - C'mon guys I don't believe no one has a clue ! any hint will do Pin
Peter Shaw22-Apr-20 11:22
professionalPeter Shaw22-Apr-20 11:22 
GeneralRe: Access WebApi remotely - C'mon guys I don't believe no one has a clue ! any hint will do Pin
pkfox22-Apr-20 13:05
professionalpkfox22-Apr-20 13:05 
GeneralRe: Access WebApi remotely - C'mon guys I don't believe no one has a clue ! any hint will do Pin
Peter Shaw22-Apr-20 13:12
professionalPeter Shaw22-Apr-20 13:12 
GeneralRe: Access WebApi remotely - C'mon guys I don't believe no one has a clue ! any hint will do Pin
pkfox22-Apr-20 13:16
professionalpkfox22-Apr-20 13:16 
GeneralRe: Access WebApi remotely - C'mon guys I don't believe no one has a clue ! any hint will do Pin
Peter Shaw22-Apr-20 13:25
professionalPeter Shaw22-Apr-20 13:25 

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.