I'm trying to create an ATM simulator in C# and I kind of stuck with the log in. I'm using a class called User which I defined as follows:
public class User
{
public string userName { get; set; }
public string password { get; set; }
public int savingsAcct { get; set; }
public int checkAcct { get; set; }
}
I've created three instances of my class to represent the three accounts I will be using. So I was wondering how can I make a two dimensional array that will accept both strings and ints.
I think I can use a two dimensional array for the log because I can use a for loop to traverse the array and check the username and password of each account to see if they match. I know I could use a data base or something else but I'm still relatively new to C# so I'm not looking for something efficient, I'm just looking for something that works. Any help would be much appreciated.
class myClass{ public string myStringProperty{ get; set; } public int myIntProperty{ get; set; }}and thenmyClass[,] my2dArrayStringAndInt;nametype[,](wherenametypeisstringorintordouble). You can also use aclassto define thisnametype. That is, you define the array (or the list, or the dictionary or any other collection) on account of a class you are creating. This class can have 2 properties, andintvariable and astringvariable; make an array of it and there you have it: and array with string and int values.List<User>? It is unclear to me what you're trying to accomplish with a 2-dimensional array from your question - if you're just trying to store the information in yourUserobjects aList<User>orUser[]is definitely the way to go.Dictionary<string, int[]>but you will have to clarify your question. What is expected in each dimension of the array? What is the purpose of the array?