archana roy
archana roy

Reputation:

String array in asp.net

I have a string array(strLarge) containing 5 values say 1,2,3,4,5. I have another string(strSmall) containing a value say 3.

Now I need to remove this strSmall from strLarge and finally get the result as 1,2,4,5.

Upvotes: 1

Views: 2484

Answers (3)

Davit Siradeghyan
Davit Siradeghyan

Reputation: 6323

use Except() for strLarge

Upvotes: 1

rahul
rahul

Reputation: 187050

strLarge.Except(strSmall);

in LINQ

Produces the set difference of two sequences.

See

msdn

Upvotes: 3

grega g
grega g

Reputation: 1089

   string[] strLarge = { "1", "2", "3", "4", "5" };
   string[] strSmall = { "3" };

   strLarge = strLarge.Where(x => !strSmall.Contains(x)).ToArray();

Upvotes: 1

Related Questions