I have declared my array like this,
string[] timeArrivalArray = new string[10];
Now, let's assume that on every click on the add button, something is inserting there.
However I want to use an if
condition to a certain index.
I want to use something like this
if (timeArrivalArray[] == [2]) {
}
Now whenever I click the button
, the timeArrivalArray[]
will check if it's already in the 2nd index and then execute the code. tl;dr I just want to use the if
condition to the 2nd index, how can this be?
EDIT:
My problem is it's throwing excemption in the first increment. I have a button
and something inserting from some variables. However, the code above is inserted in this
if (timeArrivalArray[] == [2]) {
//*insert variable this*
} else {
// *insert variable that*
}
EDIT 2:
Yes it's not the correct syntax and I just know how to do it. But the root of my problem is this
DateTime theCalcu = DateTime.ParseExact(timeArrivalArray[2], "h:mm tt", System.Globalization.CultureInfo.InvariantCulture);
It's throwing me String reference not set to an instance of a String.
Maybe because he can't find any index to the preceding indexes.
Any suggestion would do.