2
Answers

int[] reference issue

Sherwin Hamidi

Sherwin Hamidi

16y
5.5k
1
I'm trying to build a high performance windows application that does basic calculations on many different data sets.  Can anyone explain to me why this always returns false???

            int[] x = new int[10] { 10015, 10, 9, 8, 7, 6, 5, 4, 2, 2 };
            int[] y = new int[10] { 10015, 10, 9, 8, 7, 6, 5, 4, 3, 2 };

            if (x.Equals(y)) return true;
            else return false;

I'm pretty sure that .Equals is comparing the ADDRESS of the two arrays, as opposed to the values.  Can someone help me out on what the fastest way of comparing these arrays??  no looping is HIGHLY preferred.
Answers (2)
0
Ryan Alford
NA 2.3k 891.7k 16y
in the Designer view, click on the grid, then click on the little arrow at the top right of the control.  This will open a "pop-up" window.  Choose "Edit Columns".  For the columns that you will have null, there is a property called "DefaultCellStyle".  click that and open the next window and you will see a property for "Null Value".  this value is what will show if the value is null.

or, the simpler method, don't allow nulls to come from the database.  Use Oracle's NVL() method to set a "default" value to if there is a null value.

ex.

SELECT
NVL(Customer_Name, ' ') AS 'Customer Name'
FROM Customer

that will return a blank space if the customer name is null. 

It's never good practice to have null values coming from a database query.