1

I have a class

public class IgonoreValues
{
    internal static List<string> IgonoreValuesList = new List<string>
    {
       "Merge: ","# Conflicts:"
    };
}

it has a list of strings.

Now I have a String ChangeSetInfo it contains

    commit 1084b2a815b47fb03632e5bc32a0468ceb1d4bf5
Author: shw<[email protected]>
Date:   Wed Jun 23 09:36:34 2021 +0530

    Manager Merge: 

A   Manager/EventCollectionManager.cs
A   Manager/EventCollectionTimer.cs
A   Manager/EventManager.cs
A   Manager/GitManager.cs

I want to execute a linq command line for if (!ChangeSetInfo.Contains("Merge: ") || !ChangeSetInfo.Contains("# Conflicts:"))

can any one tell me a way to do this?

1
  • Are you looking for this: ChangeSetInfos.All(changeSetInfo => !IgonoreValues. IgonoreValuesList.Contains(changeSetInfo)? Commented Jun 23, 2021 at 7:29

2 Answers 2

2

Maybe you want to check if the string contains any of those ignore-strings. Then use Any:

if (!IgonoreValues.IgonoreValuesList.Any(ChangeSetInfo.Contains))
{
   // ...
}
 

the case insensitive variant:

if (!IgonoreValues.IgonoreValuesList.Any(iv => ChangeSetInfo.Contains(iv, StringComparsion.OrdinalIgnoreCase)))
{
   // ...
}
Sign up to request clarification or add additional context in comments.

Comments

1

Try this if(!IgonoreValues.IgonoreValuesList.Any(o => ChangeSetInfo.Contains(o)))

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.