Click here to Skip to main content
15,887,214 members
Home / Discussions / C#
   

C#

 
GeneralRe: Enum Question Pin
Pete O'Hanlon18-Dec-12 8:39
mvePete O'Hanlon18-Dec-12 8:39 
AnswerRe: Enum Question Pin
Richard Deeming18-Dec-12 8:47
mveRichard Deeming18-Dec-12 8:47 
GeneralRe: Enum Question Pin
PIEBALDconsult18-Dec-12 10:37
mvePIEBALDconsult18-Dec-12 10:37 
AnswerRe: Enum Question Pin
OriginalGriff18-Dec-12 8:14
mveOriginalGriff18-Dec-12 8:14 
GeneralRe: Enum Question Pin
Kevin Marois18-Dec-12 8:17
professionalKevin Marois18-Dec-12 8:17 
GeneralRe: Enum Question Pin
OriginalGriff18-Dec-12 8:40
mveOriginalGriff18-Dec-12 8:40 
GeneralRe: Enum Question Pin
Kevin Marois18-Dec-12 8:42
professionalKevin Marois18-Dec-12 8:42 
GeneralRe: Enum Question Pin
OriginalGriff18-Dec-12 8:49
mveOriginalGriff18-Dec-12 8:49 
You could set the parameter to params MyEnum[] enums:
C#
enum MyEnum
    {
    DefaultValue,
    v1, v2
    }
void TryIt()
    {
    MyMethod(MyEnum.v1);
    MyMethod();
    }

void MyMethod(params MyEnum[] theEnum)
    {
    if (theEnum.Length == 1)
        {
        Console.WriteLine(theEnum[0]);
        }
    else if (theEnum.Length > 1)
        {
        throw new ArgumentException("Too many parameters");
        }
    }

But it is ugly and relies on run time checking which is dangerous at best.
Is there anything stopping you from just declaring two overloads?
C#
void MyMethod() { }
void MyMethod(MyEnum theEnum) { }

If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.

AnswerRe: Enum Question Pin
Richard Deeming18-Dec-12 8:53
mveRichard Deeming18-Dec-12 8:53 
GeneralRe: Enum Question Pin
SledgeHammer0118-Dec-12 10:37
SledgeHammer0118-Dec-12 10:37 
AnswerRe: Enum Question Pin
DaveyM6918-Dec-12 9:37
professionalDaveyM6918-Dec-12 9:37 
GeneralRe: Enum Question Pin
PIEBALDconsult18-Dec-12 10:43
mvePIEBALDconsult18-Dec-12 10:43 
QuestionVsIntegrationPackage: Debugging does not reload .vsct file Pin
Member 802402518-Dec-12 4:16
Member 802402518-Dec-12 4:16 
QuestionHow to shwo the values in radiobuttons and labels which are reside inside a single column of gridview Pin
Arun kumar Gautam18-Dec-12 1:47
Arun kumar Gautam18-Dec-12 1:47 
AnswerRe: How to shwo the values in radiobuttons and labels which are reside inside a single column of gridview Pin
Richard MacCutchan18-Dec-12 7:11
mveRichard MacCutchan18-Dec-12 7:11 
QuestionReflection question (for <= .NET 3.5) Pin
MarkB77718-Dec-12 0:24
MarkB77718-Dec-12 0:24 
AnswerRe: Reflection question (for <= .NET 3.5) Pin
Richard Deeming18-Dec-12 1:39
mveRichard Deeming18-Dec-12 1:39 
GeneralRe: Reflection question (for <= .NET 3.5) Pin
MarkB77718-Dec-12 8:50
MarkB77718-Dec-12 8:50 
AnswerRe: Reflection question (for <= .NET 3.5) Pin
PIEBALDconsult18-Dec-12 5:17
mvePIEBALDconsult18-Dec-12 5:17 
GeneralRe: Reflection question (for <= .NET 3.5) Pin
MarkB77718-Dec-12 8:53
MarkB77718-Dec-12 8:53 
Questioncrystalreport Pin
mehdi jan17-Dec-12 19:26
mehdi jan17-Dec-12 19:26 
AnswerRe: crystalreport Pin
Mycroft Holmes17-Dec-12 21:22
professionalMycroft Holmes17-Dec-12 21:22 
QuestionFTP Pin
dineshvalluru1116-Dec-12 20:39
dineshvalluru1116-Dec-12 20:39 
AnswerRe: FTP Pin
Sivaraman Dhamodharan16-Dec-12 20:44
Sivaraman Dhamodharan16-Dec-12 20:44 
GeneralRe: FTP Pin
dineshvalluru1116-Dec-12 21:36
dineshvalluru1116-Dec-12 21:36 

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.