Go Back   RunUO - Ultima Online Emulation > Developer's Corner > Programming > C#

C# C# Discussion

Reply
 
Thread Tools Display Modes
Old 09-12-2006, 06:25 PM   #1 (permalink)
Forum Expert
 
Cheetah2003's Avatar
 
Join Date: Jun 2006
Location: Laramie, Wyoming
Age: 36
Posts: 354
Send a message via ICQ to Cheetah2003 Send a message via AIM to Cheetah2003 Send a message via MSN to Cheetah2003 Send a message via Yahoo to Cheetah2003
Default C# equivlant of struct?

Having a background in ANSI C, I'm trying to figure out how to do something like this:

struct myStruct
{
int value1
char *string
} theStruct;

theStruct arrayOfStructs[];

How would I do something similiar in C#? If that even makes sense. Basically want an array of fields.
__________________
Take a walk on The Wild side.
Cheetah2003 is offline   Reply With Quote
Old 09-12-2006, 06:31 PM   #2 (permalink)
Forum Expert
 
Courageous's Avatar
 
Join Date: Nov 2005
Location: San Diego, CA
Posts: 1,824
Default

Plenty of examples on the net, or even in the UO code. Just get a good global search tool and look for "struct" across the code base. With UO handy, some basic C# docs on the net, as well as the SDK docs here...

http://msdn2.microsoft.com/en-us/library/ms229335.aspx

... I was able to learn C# with little assistance.

To answer your question:

http://www.c-sharpcorner.com/Language/StructuresInCSRVS.asp
http://www.c-sharpcorner.com/Code/2002/July/WorkingWithArrays.asp

C//

p.s. It's bad practice to use structs (use objects if you don't know why you're using a struct) without a good reason; a discussion of when to use them is here:

http://www.codeproject.com/csharp/structs_in_csharp.asp

Last edited by Courageous; 09-12-2006 at 06:42 PM.
Courageous is offline   Reply With Quote
Old 09-12-2006, 07:16 PM   #3 (permalink)
Forum Expert
 
Cheetah2003's Avatar
 
Join Date: Jun 2006
Location: Laramie, Wyoming
Age: 36
Posts: 354
Send a message via ICQ to Cheetah2003 Send a message via AIM to Cheetah2003 Send a message via MSN to Cheetah2003 Send a message via Yahoo to Cheetah2003
Default

Great info, thanks C.
__________________
Take a walk on The Wild side.
Cheetah2003 is offline   Reply With Quote
Old 09-13-2006, 10:44 AM   #4 (permalink)
Forum Expert
 
Join Date: Jul 2005
Location: Istanbul/Turkey
Age: 27
Posts: 425
Default

here is another advanced article that discusses how to use structs efficiently.
__________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."
noobie is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5