0

I want to create a Matrix but I do not know exactly how many rows and columns are there. I have to read .txt files and from there to get attributes. These attributes will be listen in a Matrix, sometimes for ex: 50, sometimes 20, sometimes 120 (and for sure another unknown value).

How can I create a "empty" Matrix and say: If there is not this attribute add it!

  • 1
    "Matrix" isn't a built-in c# data type. What actual data type are you using in your code? A multidimensional array? A List of custom classes? Something else? – gunr2171 Oct 21 '21 at 12:09
  • @gunr2171 two dimensional array. –  Oct 21 '21 at 12:11
  • Once you initialize an Array, it's a fixed size. Are you looking to expand an array after it's made? – gunr2171 Oct 21 '21 at 12:15
  • Do you want to add rows and columns only at the "end" or do you want to rather insert rows and columns anywhere. Anyway presumably its better that you think about creating a resized copy. – Ralf Oct 21 '21 at 12:16
  • @gunr2171 Yes, I want to expand it on the right. –  Oct 21 '21 at 12:16
  • @Ralf on the right of the two dimensional array. –  Oct 21 '21 at 12:17
  • Does this answer your question? [Adding values to a C# array](https://stackoverflow.com/questions/202813/adding-values-to-a-c-sharp-array) – gunr2171 Oct 21 '21 at 12:17
  • Best to read all data first and analyze them before setting up the array. – TaW Oct 21 '21 at 12:17

0 Answers0