Copied to clipboard

Flag this post as spam?

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


  • Mark Evans 86 posts 116 karma points
    Nov 26, 2014 @ 16:53
    Mark Evans
    0

    limiting items in foreach loop

    im trying to limit the images im looping within a media folder...

    i have tried this but its still returning all logos not stopping at 18....

    foreach (var item in MediaFolder.Descendants())
                    {
                        if (item.name == "Client Logos") // its a client logos folder
                        {
                            foreach (var mediaImage in item.Children.Take(18)) // get 18 logos
                            {
  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 26, 2014 @ 17:36
    Jan Skovgaard
    0

    Hi Mark

    How about this

    int i = '';
    foreach (var item in MediaFolder.Descendants())
                    {
                        if (item.name == "Client Logos") // its a client logos folder
                        {
                            foreach (var mediaImage in item.Children) 
                            {
                                 i++
                                 if(i < 19){
    //enter code here
                                      }
    

    Does that work?

    /Jan

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies