Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8275827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:11:42+00:00 2026-06-08T08:11:42+00:00

Please, let me give an example. Say, we have: a CheckedListBox control enumerating names

  • 0

Please, let me give an example.
Say, we have:

  1. a CheckedListBox control enumerating names of some regular expression groups.
  2. a TextBox control where a user can print some input text
  3. a Button which makes the programm check, if the input text matches the regular expression and show the values of the checked (in our CheckedListBox) groups to the user.

Let the button click event handler look like this:

Regex r = new Regex(@"^(?<Num5>\d{1,5})\:(?<SomeText>.{1,})$");
Match m = r.Match(textBox1.Text);
if (m.Success)
{
    MessageBox.Show(
        string.Concat(
            checkedListBox1.CheckedItems
                           .OfType<string>()
                           .Where(s => m.Groups[s].Success)
                           .SelectMany(s => string.Format("{0}: {1}\n",
                                                          s,
                                                          m.Groups[s].Value))));
}
else
    MessageBox.Show("Input text didn't match");

So, is there an opportunity to obtain the LINQ functionality from the Collection similar to the CheckedItemCollection (implementing similar interface list) without explicit usage of OfType or Cast methods?

P.S.: this is only an example, so, please, don’t be too critical about it..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:11:43+00:00Added an answer on June 8, 2026 at 8:11 am

    No, the CheckedItemCollection is non-generic and the compiler would not know what objects are you dealing with.
    Using

    .OfType<type>()
    

    is the best you can do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please let me know if you have any idea about it. Thanks EDIT What
Please let me know how to get the client IP address, I have tried
I'm trying to work out if this is possible, let me give an example.
I have an issue with this jquery code below. Please give me advice or
Could someone please give me some advice/ideas about how to deal with the situations
I'm not sure of the terminology here, so let me give an example. I
(Problem solved, please see the updates) I have some files that have incorrect filenames
Ok, let's suppose we have members table. There is a field called, let's say,
Please let me know what are default locations for Downloads folder on devices with
Please let me know under which subclass of the ASTNode (org.eclipse.jdt.core.dom.ASTNode) the statements with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.