Click here to Skip to main content
15,915,702 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: Windows Azure Help.... Pin
binarymax9-Apr-09 2:37
binarymax9-Apr-09 2:37 
GeneralRe: Windows Azure Help.... Pin
kostas_del9-Apr-09 8:12
kostas_del9-Apr-09 8:12 
Questionmonodevelop Pin
asugix4-Apr-09 3:00
asugix4-Apr-09 3:00 
QuestionSystem.Enum - not a class? Pin
Adrian Cole3-Apr-09 19:09
Adrian Cole3-Apr-09 19:09 
AnswerRe: System.Enum - not a class? Pin
Eddy Vluggen3-Apr-09 23:56
professionalEddy Vluggen3-Apr-09 23:56 
GeneralRe: System.Enum - not a class? Pin
Adrian Cole4-Apr-09 6:29
Adrian Cole4-Apr-09 6:29 
GeneralRe: System.Enum - not a class? Pin
Eddy Vluggen4-Apr-09 23:01
professionalEddy Vluggen4-Apr-09 23:01 
GeneralRe: System.Enum - not a class? Pin
dojohansen14-Apr-09 7:13
dojohansen14-Apr-09 7:13 
I think enum values are treated like boxed ints by default, although IIRC it's possible to use other types for the values. Whatever it is there's runtime type information available to know what enum type the value belongs to.

And we're allowed to cast between enums in the somewhat optimistic hope that their underlying values correspond.

This much can be shown by running the following simple application (requires you to create a new windows forms app and drop a button on the form and wire up the click event, as I don't include the designer.cs file here).

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    enum en { Zero, One, Two, Three };
    enum fr { Nul, Un, Deux, Trois };

    void foo(object obj)
    {
        if (obj is en) dbug("en:{0} => fr:{1}", obj, (fr)obj);
        else if (obj is fr) dbug("fr:{0} => en:{1}", obj, (en)obj);
        else dbug("?:{0} => en:{1}, fr:{2}", obj, (en)obj, (fr)obj);
    }

    
    void dbug(string s, params object[] args)
    {
        if (args.Length > 0) s = string.Format(s, args);
        Debug.WriteLine(s);
    }

    
    void button1_Click(object sender, EventArgs e)
    {
        Random r = new Random();
        for (int i = 0; i < 20; i++)
        {
            object v = r.Next(4);
            if (r.Next(100) < 33)
                foo((en)v);
            else if (r.Next(100) < 50)
                foo((fr)v);
            else foo(v);

            Thread.Sleep(500);
        }
    }
}

AnswerRe: System.Enum - not a class? Pin
PIEBALDconsult5-Apr-09 6:22
mvePIEBALDconsult5-Apr-09 6:22 
QuestionRe: System.Enum - not a class? Pin
Adrian Cole5-Apr-09 18:50
Adrian Cole5-Apr-09 18:50 
AnswerRe: System.Enum - not a class? Pin
PIEBALDconsult6-Apr-09 4:27
mvePIEBALDconsult6-Apr-09 4:27 
GeneralRe: System.Enum - not a class? Pin
Adrian Cole6-Apr-09 8:52
Adrian Cole6-Apr-09 8:52 
QuestionProblems when reimplementing c# class to f# Pin
Ravadre3-Apr-09 11:54
Ravadre3-Apr-09 11:54 
AnswerRe: Problems when reimplementing c# class to f# Pin
Kevin McFarlane3-Apr-09 12:42
Kevin McFarlane3-Apr-09 12:42 
QuestionGeneral question about allocate memory in .NET Pin
Yanshof3-Apr-09 7:05
Yanshof3-Apr-09 7:05 
AnswerRe: General question about allocate memory in .NET Pin
Luc Pattyn3-Apr-09 7:24
sitebuilderLuc Pattyn3-Apr-09 7:24 
GeneralRe: General question about allocate memory in .NET Pin
led mike3-Apr-09 8:31
led mike3-Apr-09 8:31 
GeneralRe: General question about allocate memory in .NET Pin
Luc Pattyn3-Apr-09 8:45
sitebuilderLuc Pattyn3-Apr-09 8:45 
GeneralRe: General question about allocate memory in .NET Pin
harold aptroot3-Apr-09 13:10
harold aptroot3-Apr-09 13:10 
Generalcount save Pin
AARONDAS3-Apr-09 6:42
AARONDAS3-Apr-09 6:42 
GeneralRe: count save Pin
led mike3-Apr-09 8:33
led mike3-Apr-09 8:33 
GeneralRe: count save Pin
Luc Pattyn3-Apr-09 8:49
sitebuilderLuc Pattyn3-Apr-09 8:49 
GeneralRe: count save Pin
dojohansen9-Apr-09 5:05
dojohansen9-Apr-09 5:05 
GeneralRe: count save Pin
kumarnitesh6-Apr-09 1:19
kumarnitesh6-Apr-09 1:19 
QuestionResolving the full type name Pin
Vipul Mehta3-Apr-09 2:46
Vipul Mehta3-Apr-09 2:46 

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.