Click here to Skip to main content
16,013,322 members
Home / Discussions / C#
   

C#

 
GeneralRe: Umm.. Stupid Question Pin
Nick Parker21-Jul-03 17:14
protectorNick Parker21-Jul-03 17:14 
GeneralRe: Umm.. Stupid Question Pin
J. Dunlap21-Jul-03 17:44
J. Dunlap21-Jul-03 17:44 
GeneralRe: Umm.. Stupid Question Pin
Kannan Kalyanaraman21-Jul-03 19:32
Kannan Kalyanaraman21-Jul-03 19:32 
GeneralRe: Umm.. Stupid Question Pin
James T. Johnson21-Jul-03 19:38
James T. Johnson21-Jul-03 19:38 
GeneralRe: Umm.. Stupid Question Pin
Kannan Kalyanaraman21-Jul-03 20:08
Kannan Kalyanaraman21-Jul-03 20:08 
GeneralPrinting a DataGrid Pin
Mike Osbahr21-Jul-03 11:42
Mike Osbahr21-Jul-03 11:42 
GeneralRecord Types Pin
dbetting21-Jul-03 11:28
dbetting21-Jul-03 11:28 
GeneralRe: Record Types Pin
David Stone21-Jul-03 13:44
sitebuilderDavid Stone21-Jul-03 13:44 
Well, here's what it sounds like: You need an Address type that you can use for shipping, billing, and personal addresses. You want to know if you can define a type without it being a class, you want to know the differences between properties and fields, and you want to know about globals...right? (If not, correct me. Smile | :) )

1) As for the address type. The proper way to define that in C# as a class would be:

public class Address
{
    public int addressID;
    public string address;
    public string city;
    public string state;
    public string zipCode;
    public string country;  
}

However, because you don't really have any methods that belong to the Address class, and because you are really just holding data in this class, I would make it a struct. This makes it a value type that gets created on the stack rather than the managed heap. So just change the word class to struct.

Then somewhere else in your code you could do something like this:

Address personalAddress = new Address();<br />
personalAddress.addressID = 1;<br />
personalAddress.address = "123 Anywhere St."


Or even better, you could define a constructor for your struct/class that would let you specify some of the fields so that you don't have to do so much typing. Smile | :)

2) The difference between a property and a field is that the property is really just a pair of accessor methods for the field. You still need to define the field so that the property can store information. But the benefit of properties is that you can perform validation on the data that gets passed in or perform some action at the same time. They're really quite useful.

3) There isn't any concept of a global field/method/property/whatever in C#. The closest you're going to get is to define a class and have each member be public static. That way you don't have to instantiate a member of the class in order to act on that field/method/...

If you need any further clarification don't hesitate to ask. Hope that helps. Smile | :)


Hawaian shirts and shorts work too in Summer.
People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage...

-Anna-Jayne Metcalfe on Paintballing

GeneralRe: Record Types Pin
Ista21-Jul-03 17:10
Ista21-Jul-03 17:10 
GeneralRe: Record Types Pin
dbetting22-Jul-03 2:47
dbetting22-Jul-03 2:47 
GeneralEncapsulating Database in custom class Pin
sandman_max21-Jul-03 11:15
sandman_max21-Jul-03 11:15 
GeneralRe: Encapsulating Database in custom class Pin
Rocky Moore21-Jul-03 17:10
Rocky Moore21-Jul-03 17:10 
GeneralRe: Encapsulating Database in custom class Pin
sandman_max22-Jul-03 4:43
sandman_max22-Jul-03 4:43 
GeneralListView getting the Selected Item Pin
albean21-Jul-03 9:36
albean21-Jul-03 9:36 
GeneralRe: ListView getting the Selected Item Pin
draco_iii21-Jul-03 9:39
draco_iii21-Jul-03 9:39 
GeneralRe: ListView getting the Selected Item Pin
albean21-Jul-03 11:05
albean21-Jul-03 11:05 
GeneralRe: ListView getting the Selected Item Pin
David Stone21-Jul-03 13:47
sitebuilderDavid Stone21-Jul-03 13:47 
GeneralDatatables and XML Pin
draco_iii21-Jul-03 9:32
draco_iii21-Jul-03 9:32 
GeneralRe: Datatables and XML Pin
Ista21-Jul-03 17:11
Ista21-Jul-03 17:11 
GeneralDisplaying Version and Build info in my program. Pin
frogb0x21-Jul-03 9:21
frogb0x21-Jul-03 9:21 
GeneralRe: Displaying Version and Build info in my program. Pin
Anonymous21-Jul-03 10:42
Anonymous21-Jul-03 10:42 
GeneralRe: Displaying Version and Build info in my program. Pin
frogb0x21-Jul-03 10:45
frogb0x21-Jul-03 10:45 
GeneralRe: Displaying Version and Build info in my program. Pin
sandman_max21-Jul-03 11:07
sandman_max21-Jul-03 11:07 
GeneralData source/Display memeber works but data binding doesnt Pin
Anonymous21-Jul-03 8:11
Anonymous21-Jul-03 8:11 
General.net sdk and visual studio compatability Pin
Zibar21-Jul-03 7:21
sussZibar21-Jul-03 7:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.