Luigi Z

Luigi Z

  • NA
  • 24
  • 3.6k

Check particular validation from integer Array

Jul 30 2012 3:24 PM

Hello all,
I have an array of int with a size that I don't know before.
From these values I have a StartingPoint.
From this Starting Point I have to get the next value (in progressive order from this array).

Having these object, I have to validate several integer values with certain condition,
that I summarize in the code below.

private int[] ListAsset = {121, 124, 153, 164, 156, 128};

// StartingPoint belongs always to the ListAsset
private int StartingPoint = 153;

// New Candidate Asset can belong to ListAsset and also not
private int NewCandidateA = 164; // Belongs -> KO
private int NewCandidateB = 124; // Belongs -> OK

private int NewCandidateC = 159; // Does not belongs -> OK


// Here I have to find the next asset from StartingPoint
// and check if this is valid or not.
// For example, in this case the nextAssetID is 164
// so NewCandidateA, because is equal to this values, it's not good.
// NewCandidateB is good becausa is not equal to 164 (my StartingPoint is 153)
// NewCandidateC is alsoo good because is not present in ListAsset


How can I write a method that performs this checks and, for example, returns me true or false for
this kind of validation?

Thanks in advance.


Luigi


Answers (4)