Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Other Programming > Intro Programming
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Intro Programming What is a loop? Which language is best for beginners? What is "object oreinted?" All those types of questions and more are welcome here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Intro Programming section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 9th, 2006, 01:28 PM
Registered User
 
Join Date: Mar 2006
Location: Phoenix, AZ, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to MoDulus
Default Enums VS Structs

Anyone mind explaining the differences between enums and structs. they look pretty much the same. So how are they different? Where would you use one over the other?

Thanks
Shaun
Reply With Quote
  #2 (permalink)  
Old March 9th, 2006, 08:01 PM
Wrox Technical Editor
 
Join Date: Nov 2005
Location: , , Canada.
Posts: 271
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Enumerations are a distinct type consisting of a set of named constants called the enumerator list. Every enumeration type has an underlying type, which can be any integral type except char.
Enumerations are integer-types that make code clearer and easier to maintain.

Example:

enum Days {Sat, Sun, Mon, Tue, Wed, Thu, Fri};

A structure is a value type and the instances or objects of a structure are created in stack. A struct can contain fields, methods, constants, constructors, properties, indexers, operators and even other structure types.
Structs are similar to clases, but are intended to be used to group similar items of data together.

Example:

struct MyStruct{
            static int x = 25;
            static int y = 50;

            public void SetXY(int i, int j)
            {
                        x = i;
                        y = j;
            }
            public static void ShowSum()
            {
                        int sum = x + y;
                        Console.WriteLine("The sum is {0}",sum);
            }
}

Understanding Structures in C#: http://www.c-sharpcorner.com/Languag...resInCSRVS.asp
C# Programmer's Reference enum: http://msdn.microsoft.com/library/de...ationtypes.asp

- A.Kahtava
Reply With Quote
  #3 (permalink)  
Old March 10th, 2006, 12:20 AM
Registered User
 
Join Date: Mar 2006
Location: Phoenix, AZ, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to MoDulus
Default

Thank You that makes a lot more sense now. I should know this by now, but oh well. Thanks Again

Shaun
Reply With Quote
  #4 (permalink)  
Old August 2nd, 2011, 10:54 AM
Authorized User
Points: 45, Level: 1
Points: 45, Level: 1 Points: 45, Level: 1 Points: 45, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2009
Posts: 11
Thanks: 0
Thanked 1 Time in 1 Post
Default Good post

Thanks for your help
http://www.4microsoftsolutions.com
__________________
Rajendar
Reply With Quote
  #5 (permalink)  
Old January 19th, 2012, 09:42 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default difference betweenn structures and enumeration

very helpful for me and I find one more link for difference between structure and enumeration

http://www.dotnetquestionanswers.com....msg726#msg726
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
SizeOf Structs CDMBR C# 1 February 21st, 2007 05:24 PM
declaring structs scoobie C++ Programming 3 April 6th, 2006 12:44 AM
Enums.cs allanhu BOOK: ASP.NET Website Programming Problem-Design-Solution 3 November 2nd, 2004 09:37 PM
Enums for accounts??? rcarter BOOK: ASP.NET Website Programming Problem-Design-Solution 3 November 7th, 2003 11:07 PM



All times are GMT -4. The time now is 03:41 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.