Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Amir Khan 1287 posts 2744 karma points
    Jul 23, 2018 @ 20:57
    Amir Khan
    0

    Gruoped items returns System.Linq.Lookup`2+Grouping[System.Int32,System.String]

    Hi,

    I'm looping through a multiple textbox datatype with leblender and as soon as I try to group the items it returns "System.Linq.Lookup2+Grouping[System.Int32,System.String]" instead of the value. Any ideas?

    Works:

    var istArray = editor.GetValue<Newtonsoft.Json.Linq.JArray>("list");
    var istArrayStrings = istArray.Select(x => (string)x["value"]);
    
    @foreach(var item in listArrayStrings) {
        <li>@item</li>
    }
    
    but this just returns the string above instead of the value:
    @foreach(var item in listArrayStrings.InGroupsOf(2)) {
    

    Thanks!

    Amir

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Jul 31, 2018 @ 09:35
    Simon Dingley
    100

    In your example, @item is an IEnumerable which is why you see the result you do. You need to do something more with the collection in order to render it's contents. Perhaps something along the following lines:

    var listArrayStrings = new[] { "StringOne", "StringTwo", "StringThree", "StringFour" };
    foreach (var item in listArrayStrings.InGroupsOf(2))
    {
        @string.Join(", ", item)
    }
    

    Which should produce results similar to this I think:

    StringOne, StringTwo
    StringThree, StringFour
    

    Hope that helps!

  • Amir Khan 1287 posts 2744 karma points
    Aug 17, 2018 @ 16:19
    Amir Khan
    0

    Sorry for the late reply. That did the trick, thanks Simon!

Please Sign in or register to post replies

Write your reply to:

Draft