score:3

Accepted answer
var indices = yourlist
       .where(x => x.startswith("entry"))
       .select(x => yourlist.indexof(x))
       .tolist();

var groups = indices
     .select((x,idx) => idx != indices.count - 1 
                               ? yourlist.getrange(x, indices[idx + 1] - x)
                               : yourlist.getrange(x, yourlist.count - x))
     .tolist();

score:1

void main()
{
    var data = new list<string>() { "entry1", "metadata1", "metadata2", 
                                    "entry2", "metadata3", "metadata4" };

    pairwithgroup(data).groupby(t=>t.item1).dump();
}

private ienumerable<tuple<string,string>> pairwithgroup(ienumerable<string> input) {
    string groupname = null;
    foreach (var entry in input) {
        if (entry.startswith("entry")) {
            groupname = entry;
        }
        yield return tuple.create(groupname, entry);
    }
}

score:1

key = entry1 
    value       groupname
    entry1      entry1 
    a           entry1 
    b           entry1 

key = entry2 
    value       groupname
    entry2      entry2 
    c           entry2 
    d           entry2 
    e           entry2 

score:2

using system;
using system.collections.generic;
using system.linq;
using system.text;
using system.threading.tasks;

namespace consoleapplication1
{
    class program
    {

        static void main(string[] args)
        {
            list<string> datas = new list<string>() { "entry1", "metadata1", "metadata2", "entry2", "metadata3", "metadata4" };
            list<list<string>> grouped = new list<list<string>>();
            int count = -1;
            foreach (string e in datas)
            {
                if (e.startswith("entry"))
                {
                    grouped.add(new list<string>());
                    grouped[++count].add(e);
                }
                else
                {
                    grouped[count].add(e);
                }
            }
            for (int i = 0; i < grouped.count; i++)
            {
                for (int j = 0; j < grouped[i].count; j++)
                {
                    console.writeline(grouped[i][j]);
                }
                console.writeline();
            }


        }
    }
}

score:2

var data = new list<string>() { "key1", "value1", "value2", 
                                "key2", "value3", "value4" };
string workingkey = null; 
data.tolookup(item => {
    if(item.startswith("key"))
    {
        workingkey = item;
        return string.empty; //use whatever here
    }
    return workingkey;
}).where(g => g.key != string.empty); //make sure to enumerate this if you plan on setting workingkey after this edit: where is enumerating so no need to enumerate again

Related Query

More Query from same tag