Jump to content

Image of the Day

#animation 2/14

Sweet piggy, isn't it?

#gamedev #indiedev #indiegame #GamersUnite #screenshotsaturday #unity3d https://t.co/lscyvCxrPR
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net's newsletters to receive the latest updates and exclusive content.


Sign up now

simple c# question

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 phil67rpg   Members   

344
Like
0Likes
Like

Posted 27 February 2012 - 03:47 PM

I am trying to convert a enum type to a string.I am getting an error with the following line: label2.Text = month.
here is the code I am working with.

public enum Months { January=1,Febraury...December};

private void button1_Click(object sender, EventArgs e)
{
int num = Convert.ToInt32(textBox1.Text);
Months month = (Months)num;
this.Text=(month);
}

#2 SiCrane   Moderators   

11665
Like
1Likes
Like

Posted 27 February 2012 - 03:55 PM

Did you try Enum.GetName()?

#3 blackbook   Members   

110
Like
1Likes
Like

Posted 27 February 2012 - 04:35 PM

You can call .ToString() on any object.

http://msdn.microsof...t.tostring.aspx

Here's an enum.ToString() webpage.

http://www.dotnetperls.com/enum-tostring




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.