lundi 28 mars 2016

how to get random amount of details from a list or var in c#

I'm reading result from an json file inside the local project.it returns more than 4000 result.I want to get only random number of results (between 500- 1000) from that result.

 var finalResultz = finalResults("All","All","All");//step one

in here it returns more than 4000 results.then I put into a list like this.

List<Results> searchOne = new List<Results>();//step two
            foreach(var itms in finalResultz)
            {
                searchOne.Add(new Results 
                {
                    resultDestination = returnRegionName(itms.areaDestination),
                    mainImageurl = itms.testingImageUrl
                });
            }


            ViewBag.requested = searchOne;

but I want to get only the results like I said.I want to resize the count in step one or in step two.how can I do that.hope your help.




Aucun commentaire:

Enregistrer un commentaire