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

  • Home
  • SEARCH
  • 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 8610041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:02:04+00:00 2026-06-12T04:02:04+00:00

I have a string array in this format (each line is a slot in

  • 0

I have a string array in this format (each line is a slot in the array):

IT1
PID
Ref
Ref
REF
IT1
PID
REF
IT1
PID
Ref
REF
…

I want to extract each IT1 through the last REF into a new array using LINQ. The new result would be an IEnumerable<IEnumerable<string>>.

Using the above string slot array example, the new IEnumerable collection should have 3 IEnumerable<string> in it.

For example:

class 1
IT1
PID
Ref
Ref
REF
end class 1

class 2
IT1
PID
REF
end class 2

class 3
IT1
PID
Ref
REF
end class 3
…

Notice some sections of the array have 1 REF, some 2 REF and some 3 REF.

How can I use LINQ to extract each section from IT1 through the last REF into a new collection of IEnumerable<IEnumerable<string>>?

Psudo code…

var result = arrayData.Select(s => s.StartsWith("IT1")
.GroupBy(...)
.Select(result => new {IT1 through last ref goes here})
.ToArray();

Thanks all for the help!

  • 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-12T04:02:05+00:00Added an answer on June 12, 2026 at 4:02 am

    You can partition the array using GroupBy and some temporary state like this:

    var counter = 0;
    var arrays = input.GroupBy(s => counter += s == "IT1" ? 1 : 0)
                      .Select(g => g.ToArray())
                      .ToArray();
    

    This will give you an array of arrays; each sub-array will start with an "IT1" element and end with whatever your input had before the next "IT1". If your data is valid, that will be a "REF". If the data is invalid, you need to specify what should happen in this case.

    I ‘m not so sure how you expect these arrays to be converted into anonymous objects though. Anonymous objects might have an unknown type name, but they are still very strongly typed: you cannot dynamically decide the amount, names, and types of their members.

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

Sidebar

Related Questions

I have 10 data's in string array.In this 10 data, each of the data's
I have this array: string[,] productData = new string[5,7]; I bind it to a
I have string that look like Array that fetched from other webservice like this
I have this string of numbers var array = 1,6,2,9,5 which is retrieved from
Basically I have this string $str=word1 word2 word3; I need array( 'word1', 'word2', 'word3'
I have an array similar to this: array(2) { [0]=> array(2) { [code]=> string(2)
I have an array with this structure: array(4) { [0]=> array(x) { [0]=> string(x)London
I have a string like this: TEST.DATA.Data.COR.Point,2;TEST.DATA.Data.COR.Point,5;TEST.DATA.Data.COR.Point,12;TEST.DATA.Data.COR.Point,12;TEST.DATA.Data.COR.WordTOFIND,18 I have a list of array with
If you have a string of 1,2,3,1,5,7 you can put this in an array
I have this 4 Dimensional array to store String values which are used to

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.