當前位置: 首頁>>代碼示例>>C#>>正文


C# List.Select方法代碼示例

本文整理匯總了C#中Model.List.Select方法的典型用法代碼示例。如果您正苦於以下問題:C# List.Select方法的具體用法?C# List.Select怎麽用?C# List.Select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Model.List的用法示例。


在下文中一共展示了List.Select方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetRecommendations

        public static List<Movie> GetRecommendations(List<Movie> all, Dictionary<int, int> newRanks, List<Tuple<int, int, float>> oldRanks)
        {
            int newUserId = 0;
            Ratings ratings = new Ratings();

            foreach (var r in oldRanks)
            {
                ratings.Add(r.Item1, r.Item2, r.Item3);
                if (r.Item1 > newUserId) newUserId = r.Item1;
            }

            // this makes us sure that the new user has a unique id (bigger than all other)
            newUserId = newUserId + 1;

            foreach (var k in newRanks)
            {
                ratings.Add(newUserId, k.Key, (float)k.Value);
            }

            var engine = new BiPolarSlopeOne();

            // different algorithm:
            // var engine = new UserItemBaseline();

            engine.Ratings = ratings;

            engine.Train(); // warning: this could take some time!

            return all.Select(m =>
                                {
                                    m.Rank = engine.Predict(newUserId, m.Id); // do the prediction!
                                    return m;
                                }).ToList();
        }
開發者ID:jitsolutions,項目名稱:dotnet-recommend,代碼行數:34,代碼來源:Engine.cs

示例2: GetDoctorByIds

 public List<md_docter> GetDoctorByIds(List<string> ids)
 {
     string id = string.Join(",", ids.Select(t => t));
     string sql = @"SELECT *
                     FROM md_docter
                     where FIND_IN_SET(pkid,@ids)";
     List<md_docter> resultlist = sqlHelper.ExecuteObjects<md_docter>(sql, new MySqlParameter("ids", id));
     return resultlist;
 }
開發者ID:lehprject,項目名稱:sfjyDMS,代碼行數:9,代碼來源:md_docter_DA.cs

示例3: SelectTests

 public async Task<List<TestNodeAssembly>> SelectTests(List<string> testAssemblies = null)
 {
     var testsRootNode = await _testsTask;
     testsRootNode.IsIncluded = true;
     if(testAssemblies != null)
     {
         return testsRootNode.TestNodeAssemblies.Where(a => 
             testAssemblies.Select(Path.GetFileNameWithoutExtension).Contains(a.Name)).ToList();
     }
     else
     {
         return testsRootNode.TestNodeAssemblies.ToList();
     }
 }
開發者ID:Refresh06,項目名稱:visualmutator,代碼行數:14,代碼來源:ITestsSelectStrategy.cs

示例4: GetCouponsDetailByIds

 public List<promotion_coupons_detail> GetCouponsDetailByIds(List<int> ids)
 {
     string id = string.Join(",", ids.Select(t => t));
     string sql = @"SELECT *
                     FROM promotion_coupons_detail
                     where FIND_IN_SET(pkid,@ids)";
     List<promotion_coupons_detail> resultlist = sqlHelper.ExecuteObjects<promotion_coupons_detail>(sql, new MySqlParameter("ids", id));
     return resultlist;
 }
開發者ID:lehprject,項目名稱:sfjyDMS,代碼行數:9,代碼來源:promotion_events_DA.cs

示例5: ToDto

 private List<UsuarioDto> ToDto(List<Usuario> usuarios)
 {
     return usuarios.Select(u => new UsuarioDto {Login = u.Login, Saldo = u.Saldo}).ToList();
 }
開發者ID:TiagoSoczek,項目名稱:BSI-ATM,代碼行數:4,代碼來源:UsuarioService.cs

示例6: SelectMonth

 private void SelectMonth()
 {
     DateTime now = new DateTime(int.Parse(this.YearDropDownList.SelectedValue), 1, 1);
     DateTime startMonth = new DateTime(now.Year, 1, 1);
     List<DateTime> months = new List<DateTime>(12);
     for (int i = 0; i < 12; i++)
     {
         months.Add(startMonth.AddMonths(i));
     }
     this.MonthDropDownList.DataSource = months.Select(m => new { MonthText = m.ToString("MMMM"), m.Month });
     this.MonthDropDownList.DataBind();
     this.SelectDay();
 }
開發者ID:ksikes,項目名稱:Amazon.Powershell,代碼行數:13,代碼來源:PetDetails.aspx.cs

示例7: PerformRandomFlight

        private int[] PerformRandomFlight(int[] xi, double alfa)
        {
            int[] result = new int[n];
            xi.CopyTo(result, 0);

            if(alfa < 0 || alfa >= n ) throw new Exception("Zla alfa");
            var rand = new Random();

            int nrOfElementsToShuffle = (int) (alfa*rand.NextDouble());

            //choosing elements to be shuffled
            var positionsToShuffle = new List<int>();
            var needed = nrOfElementsToShuffle;
            var available = n;

            while (positionsToShuffle.Count < nrOfElementsToShuffle) {
               if( rand.NextDouble() < ((double)needed / available) )
               {
                  positionsToShuffle.Add(xi[available - 1]);
                  needed--;
               }
               available--;
            }

            //CHANGEME
            //shuffling them
            var valuesLeft = positionsToShuffle.Select(i => xi[i]).ToList();

            int left = nrOfElementsToShuffle;
            foreach (int i in positionsToShuffle)
            {
                result[i] = valuesLeft[rand.Next(left)];
            //                valuesLeft.Remove(xi[i]);
                valuesLeft.Remove(result[i]);
                left--;
            }

            if(left != 0) throw new Exception("nie powinnno nic zostac!");

            return result;
        }
開發者ID:Kristofers93,項目名稱:qap-project,代碼行數:41,代碼來源:FireflyAlgorithm.cs


注:本文中的Model.List.Select方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。