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


C# List.Any方法代碼示例

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


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

示例1: Grade

        protected void Grade()
        {
            string whatTest = Request.Form["what"];

            string connectionString = WebConfigurationManager.ConnectionStrings["JE-Banken"].ConnectionString;
            NpgsqlConnection conn = new NpgsqlConnection(connectionString);

            User u = (User)Session["user"];

            int antalFragor = 0;
            int antalRatt = 0;

            XmlDocument doc = new XmlDocument();
            List<Svar> svarList = new List<Svar>();
            List<testdel> tdList = new List<testdel>();

            doc.Load(MapPath("/tests/" + u.employeenumber.ToString() + ".xml"));

            XmlNodeList nodeList = doc.SelectNodes("/formular/fraga");
            foreach (XmlNode fraga in nodeList)
            {
                antalFragor++;
                Svar s = new Svar();
                s.del = fraga["del"].InnerText;
                if (!tdList.Any(x => x.del == fraga["del"].InnerText))
                {
                    testdel td = new testdel();
                    td.del = fraga["del"].InnerText;
                    tdList.Add(td);
                }

                int svarAntalRatt = 0;
                int antalSvaradeRatt = 0;

                foreach (XmlNode svar in fraga["svar"].ChildNodes)
                {
                    if (Convert.ToInt32(svar.Attributes["ratt"].Value) == 1)
                    {
                        svarAntalRatt++;
                    }

                    if (Convert.ToInt32(svar.Attributes["ratt"].Value) == 1 && Convert.ToInt32(svar.Attributes["gissat"].Value) == 1)
                    {
                        antalSvaradeRatt++;
                    }
                    }

                if (svarAntalRatt == antalSvaradeRatt)
                {
                    antalRatt++;
                    s.ratt = true;
                }
                svarList.Add(s);
            }

            Response.Write("<h2 class='antalRatt'>Antal poäng: " + antalRatt + "/" + antalFragor + "</h2>");
            Response.Write("<div class='responseHidden'></div>");

            foreach (testdel td in tdList)
            {
                foreach (Svar s in svarList)
                {
                    if (s.del == td.del)
                    {
                        td.antalFragor++;

                        if (s.ratt)
                        {
                            td.antalRatt++;
                        }
                    }
                }
            }

            string score = antalRatt.ToString() + "/" + antalFragor.ToString();
            bool passed = false;
            bool totalpassed = false;
            bool testpartpassed = true;

            if ((Convert.ToDouble(antalRatt) / Convert.ToDouble(antalFragor)) >= 0.7)
            {
                totalpassed = true;
            }

            foreach (testdel td in tdList)
            {
                if ((Convert.ToDouble(td.antalRatt) / Convert.ToDouble(td.antalFragor)) < 0.6)
                {
                    testpartpassed = false;
                    // 1 = knowledgetest
                    // 0 = licensetest
                    if (whatTest != "1")
                    {
                        string sql2 = "UPDATE employees SET licensed = @licensed WHERE employeenumber=" + u.employeenumber;
                        NpgsqlCommand cmd2 = new NpgsqlCommand(sql2, conn);
                        cmd2.Parameters.AddWithValue("licensed", false);
                        conn.Open();
                        cmd2.ExecuteScalar();
                        conn.Close();
                    }
//.........這裏部分代碼省略.........
開發者ID:Myrtass,項目名稱:JE-Banken,代碼行數:101,代碼來源:Response.aspx.cs

示例2: IsOwnerOf

 /// <summary>Checks whether the current user is the owner of the item with the specified Id.</summary>
 /// <param name="itemId">The Id of the item in question.</param>
 /// <returns>True if the user owns the item, false if not.</returns>
 public static bool IsOwnerOf(int itemId)
 {
     List<Item> items = new List<Item>(GetOwnedFileInfosByEmail(_sessionUser.Email));
     items.AddRange(GetOwnedPackagesByEmail(_sessionUser.Email));
     return items.Any<Item>(item => item.Id == itemId);
 }
開發者ID:Crelde,項目名稱:ClientBNDN,代碼行數:9,代碼來源:Controller.cs


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