1

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.

1
  • 1
    What's your framework version? Commented Oct 1, 2009 at 11:51

3 Answers 3

3
strLarge.Except(strSmall);

in LINQ

Produces the set difference of two sequences.

See

msdn

Sign up to request clarification or add additional context in comments.

1 Comment

Add ".ToArray()" to the end if the result should an array of String and not an IEnumerable<String>.
1
   string[] strLarge = { "1", "2", "3", "4", "5" };
   string[] strSmall = { "3" };

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

Comments

1

use Except() for strLarge

Comments

Your Answer

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