L
L
LebedevStr2019-02-05 18:47:26
C++ / C#
LebedevStr, 2019-02-05 18:47:26

How to build a list rule in C#?

Hello. There is this code:

using System;
using System.Collections.Generic;
using System.Text;
using DynamicPluginData;
namespace DatacolDynamicPluginNS
                            {                
                                public class DynamicPluginClass
                                {     
                                    public static List<string> processLinks(List<string> links, ItemInfo itemInfo, GlobalInfo globalInfo)
                                    {
                                       return links;
                                    }
                                }
                            }

links contains a list of links.
The task is to place all links in which the occurrence of "navi" occurs at the end of the list.
Or is it already necessary to send it to freelance?
Here is an example of code that "cuts" links, maybe something will tell you.
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using DynamicPluginData;
 
                            namespace DatacolDynamicPluginNS
                            {                
                                public class DynamicPluginClass
                                {     
                                    public static List<string> processLinks(List<string> links, ItemInfo itemInfo, GlobalInfo globalInfo)
                                    {
                                        for(int i=0;i<links.Count;i++)
                                            links[i] = Regex.Replace(links[i],"\\?p=[\\d]{1,}\\?p","?p");
                                       return links;
                                    }
                                }
                            }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
John_Nash, 2019-02-05
@John_Nash

links.Where(a => !a.Contains("navi")).ToList().AddRange(links.Where(a => a.Contains("navi")));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question