0

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.

2
  • You did't use any identifier for the array. Commented May 20, 2014 at 9:04
  • 1. Im not sure how you can have a 0 column 2d array and 2. every element will be null since you havent initialized anything. 3. @MeysamTolouee - they are the same thing Commented May 20, 2014 at 9:04

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.