c# - Array of array references -


i have 3 string arrays:

private readonly string[] pmctablecolumnnames = new string[] { "pmcip", "description", "cam1referencepoints", "cam2referencepoints", "dataserverip" }; private readonly string[] pmdtablecolumnnames = new string[] { "pmdip", "description" }; private readonly string[] pmdzonestablecolumnnames = new string[] { "pmdip", "description", "zone" }; 

i want construct array points these arrays as:

private var[] arrayreferences = new var[] { pmctablecolumnnames, pmdtablecolumnnames, pmdzonestablecolumnnames }; 

when put index (arrayreferences) array, want elements of specific array this:

string[] _pmdtablecolumnnames = arrayreferences[1]; 

how can that?

you can create array of arrays:

private string[][] arrayreferences; 

note you'll have initialise arrayreferences in constructor since can't reference other arrays in field initialiser. i.e.

public class classname { private readonly string[] pmctablecolumnnames = new string[] { "pmcip", "description", "cam1referencepoints", "cam2referencepoints", "dataserverip" }; private readonly string[] pmdtablecolumnnames = new string[] { "pmdip", "description" }; private readonly string[] pmdzonestablecolumnnames = new string[] { "pmdip", "description", "zone" }; private string[][] arrayreferences; public classname() { arrayreferences = new string[][] { pmctablecolumnnames, pmdtablecolumnnames, pmdzonestablecolumnnames }; } void somemethod() { string[] _pmdtablecolumnnames = arrayreferences[1]; } } 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -