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 731951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:05:10+00:00 2026-05-14T07:05:10+00:00

How can i find all subsets of a set using c#? here set is

  • 0

How can i find all subsets of a set using c#? here set is a sentence(string).for example:
s=”i am nik”;What will be the code for that?

here the subsets of s will be-> i, am, nik, i am, i nik, am nik, i am nik.

  • 1 1 Answer
  • 1 View
  • 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-05-14T07:05:10+00:00Added an answer on May 14, 2026 at 7:05 am

    Here’s a function I wrote to find all incontiguous subsets from a given array.

    List<T[]> CreateSubsets<T>(T[] originalArray)
    {
        List<T[]> subsets = new List<T[]>();
    
        for (int i = 0; i < originalArray.Length; i++)
        {
            int subsetCount = subsets.Count;
            subsets.Add(new T[] { originalArray[i] });
    
            for (int j = 0; j < subsetCount; j++)
            {
                T[] newSubset = new T[subsets[j].Length + 1];
                subsets[j].CopyTo(newSubset, 0);
                newSubset[newSubset.Length - 1] = originalArray[i];
                subsets.Add(newSubset);
            }
        }
    
        return subsets;
    }
    

    So given an integer array of 1,2,3,4,5, it will return a List<int[]> containing 31 subsets.

    Edit: Based upon your update, you can generate the 6 subsets you need with the function above and by using string.Split(‘ ‘) on your original sentence. Consider:

    string originalString = "i am nik";
    List<string[]> subsets = CreateSubsets(originalString.Split(' '));
    
    foreach (string[] subset in subsets)
    {
        Console.WriteLine(string.Join("\t", subset));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How i can find all the windows created by a particular process using c#?
I am wondering how i can find all rows that have the same ID
Can we find all tables in the msaccess using sql . as we do
how can i find all the anchor tags with source pdf $string=hello this is
Using NDepend , how can I find all, direct and indirect, uses of a
I'm trying to find all records in database that have exactly the same set
Possible Duplicate: How to find all possible subsets of a given array? How can
Is there a place where I can find all the keycodes for keys on
Is there some way I can find all active spies in sinon.js? I'd like
How can I find all column values in a column which have trailing spaces?

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.