473,473 Members | 2,176 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Error in enum operations

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

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

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Text;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsApplication1
  12. {
  13.     public enum numbers
  14.     {
  15.         zero, 
  16.         one, 
  17.         two
  18.     }
  19.     public partial class Form1 : Form
  20.     {
  21.         public Form1()
  22.         {
  23.             InitializeComponent();
  24.         }
  25.  
  26.         private void Form1_Load(object sender, EventArgs e)
  27.         {
  28.             MessageBox.Show(((int)numbers.two * 2).tostring()); 
  29.         }
  30.     }
  31. }
  32.  
  33.  
  34.  

can any one solve my problem,please
Aug 29 '07 #1
3 1240
nateraaaa
663 Recognized Expert Contributor
i got an error with enum implementatios in C#.net

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

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Text;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsApplication1
  12. {
  13.     public enum numbers
  14.     {
  15.         zero, 
  16.         one, 
  17.         two
  18.     }
  19.     public partial class Form1 : Form
  20.     {
  21.         public Form1()
  22.         {
  23.             InitializeComponent();
  24.         }
  25.  
  26.         private void Form1_Load(object sender, EventArgs e)
  27.         {
  28.             MessageBox.Show(((int)numbers.two * 2).tostring()); 
  29.         }
  30.     }
  31. }
  32.  
  33.  
  34.  

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
Aug 29 '07 #2
swetha82
7 New Member
ok thank you, i felt the both are same. any way thanks
Aug 29 '07 #3
Plater
7,872 Recognized Expert Expert
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
Aug 29 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Rennie deGraaf | last post by:
If a C++ I/O operation fails, then how can I determine the cause? For instance, in C, I'd do something like this: FILE* file; file = fopen("foo.txt", "r"); if (file == NULL) { switch(errno)...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
9
by: ccwork | last post by:
Hi all, We can define some magic number with #define: #define OPERATION_1 0x00000001 #define OPERATION_2 0x00000002 #define OPERATION_3 0x00000003 .... We can also do that with enum: enum...
3
by: Matt | last post by:
Hi, Recently we had some code like this cause a failure: MyEnum myEnum = (MyEnum) (int) dt; i.e. reading an int out of the database and casting it into a type-safe enum. The thought...
5
by: steve bull | last post by:
I am sure this is a really basic question but I don't see an easy way to do it. I have an enum public enum ColorType { red = 0, green = 1, blue = 2, hue = 3,
21
by: dllhell | last post by:
hi all, I have a problem with creating proc with a enum as a param. I wish to pass an enumeration in proc in which one I intend to do some operations with enumeration, but I don't know which one...
35
by: dtschoepe | last post by:
Greetings. I am working on an assignment and can't seem to get the right concept for something I'm attempting to do with enum data types. I have defined the following in my code: enum color...
35
by: =?Utf-8?B?UElFQkFMRA==?= | last post by:
I'd really like to be able to constrain a generic type to System.Enum or, better, enum. But of course that results in "Compiler Error CS0702". So far I've been checking the type parameter at...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.