Error in enum operations

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • swetha82
    New Member
    • Jul 2007
    • 7

    Error in enum operations

    i got an error with enum implementatios in C#.net

    Error 1 'int' does not contain a definition for 'tostring' , code fallows...

    Code:
    
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    
    namespace WindowsApplication1
    {
        public enum numbers
        {
            zero, 
            one, 
            two
        }
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                MessageBox.Show(((int)numbers.two * 2).tostring()); 
            }
        }
    }

    can any one solve my problem,please
  • nateraaaa
    Recognized Expert Contributor
    • May 2007
    • 664

    #2
    Originally posted by swetha82
    i got an error with enum implementatios in C#.net

    Error 1 'int' does not contain a definition for 'tostring' , code fallows...

    Code:
    
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    
    namespace WindowsApplication1
    {
        public enum numbers
        {
            zero, 
            one, 
            two
        }
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                MessageBox.Show(((int)numbers.two * 2).tostring()); 
            }
        }
    }

    can any one solve my problem,please
    tostring() is not the same as ToString().
    try creating an int variable in your page load that does your * 2 calculation. Then do a .ToString() on that variable in your MessageBox.

    Nathan

    Comment

    • swetha82
      New Member
      • Jul 2007
      • 7

      #3
      ok thank you, i felt the both are same. any way thanks

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Originally posted by swetha82
        ok thank you, i felt the both are same. any way thanks
        All code in c# is case-sensitive.
        ToString() is valid, tostring() is not

        Comment

        Working...