5

I have this piece of code.

I want to convert this into lambda expression. How to reach this

string[] MyString= ConfigurationManager.AppSettings["MyStringData"].Split(',');

foreach (string res in MyString)
{
    if (res != "MyName")
    {
        btnshowname.Visible = false;
    }
    else if (res == "MyName")
    {
        btnshowname.Visible = true;
        break;
    }
}

Tell me the lambda expression please and how to achieve this

1 Answer 1

9
btnshowname.Visible = MyString.Any(s => s == "MyName");
Sign up to request clarification or add additional context in comments.

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.