Storing 3 values for all 20 elements in an array

P3rry

What would be the best way to have 3 values stored for every element in a 20 element sized array? E.g. An array of 20 people, which can store their name, address and phone number.

Would it be along the lines of

int[][] myArray = new int[20][3];

or something similar?

Thanks

Kamil Budziewski

It should be rather a List of class objects:

public class Person
{
    public string Name { get; set; }
    public string SecondName { get; set; }
    public string Street { get; set; }
}

 List<Person> personList = new List<Person>();
 personList.Add(new Person()
 {
      Name = "Sample",
      SecondName = "S",
      Street = "4825235186"
 });

Now you can have more dynamic way of having different count of persons in list. Not a static number. Doing it this style will be much more elastic, because you can add new fields to class and access fields by list[i].Name instead of array[i][1]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Storing all values in the array in Python

Storing all values of an iterator

Storing the values of two array lists on a dynamic 3 dimensional array

d3.each() storing values one at a time, not all at once

Array not storing values

Java Array Storing Values

How to get the values of all the elements in an XML into an array?

check all elements against values in an array JQuery

Storing all elements as a list in Python

Python: Storing values in a 3D array to csv

how to print array of object in array of array (keys, values all are elements)

Ignoring CSV values with openCSV + Storing int values from CSV file in separate two-dimensional array elements

Storing an array of elements using Cypress

Storing an array of three values in Java

VBA, Storing filtered values in array

Storing a PostgreSQL ARRAY of ENUM values

Java storing file values into an array

Binded values of checkbox is not storing into array

Shorcut to storing incremented values in array?

PHP - Array For Loop Not Storing Values

Storing and Printing values in Array - VBA

Storing multiple values in $_SESSION array

Storing Values into an Array of Pointers to Structs

Looping an Array and storing values in a table

Storing all the array values into single variable and then using that value as css property through javascript

Unable to get all the values from JSON_ARRAY_ELEMENTS()

Loop through all the elements of an array into jsonb and modify values

Replace all elements of Python NumPy Array that are EQUAL to some values

Assigning values to all the elements of a dynamically allocated pointer array?

TOP Ranking

HotTag

Archive