Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


simple c# question


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   -  Reputation: 767

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);
}

Sponsor:

#2 SiCrane   Moderators   -  Reputation: 9625

Like
1Likes
Like

Posted 27 February 2012 - 03:55 PM

Did you try Enum.GetName()?

#3 blackbook   Members   -  Reputation: 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.



PARTNERS