简体   繁体   中英

Remove Null from 2D Array

I have a 2D array object fixed Size

object[,] = new object[1,50];

But Some times some sections of this null which i don't want in my Operation. I wanted to Remove Nulls from 2D Array.

Where I couldn't find Remove Function with this. I don't want any loop to check each index.

How to do this.

Thanks in Advance.

An array is fixed size; you cannot "remove" anything . You can replace values with other values, via the indexer - but frankly I would say that null is the classic "doesn't have a value" for something we only know as object .

So you have a few options:

  • if the problem is borders: create the array with the correct size so that there are no borders
  • or initialize all the values to non-null values at the start
  • or loop over the cells and replace null values with non-values at your convenience

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM