I am trying to store two related integers together in the one data structure. For example, I have a Care Registration Number and a User ID that I want to store together. What's the best way to do this? A two dimensional array? Or is there another option?
Asked
Active
Viewed 79 times
-3
-
1You can encapsulate both integers in a class object. – Tea With Cookies Nov 21 '14 at 09:06
1 Answers
-1
I would use a struct or a class:
public struct User
{
public int UserID;
public int RegistrationNumber;
}
EDIT: for the discussion on struct vs. class I think this is a good answer.
-
1
-
-
1It's not about getting the point, it's about adding an answer that fits the question. – ChrisBint Nov 21 '14 at 09:12
-
1
-
To start with, use a `class` and decent properties. `struct` and public fields are exceptional features, best avoided. – H H Nov 21 '14 at 12:18