Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 7 developers from Canada and 18 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!


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: 100

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: 10850

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