当前位置: 首页>>代码示例>>C#>>正文


C# List.Contains方法代码示例

本文整理汇总了C#中WebApplication1.List.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# List.Contains方法的具体用法?C# List.Contains怎么用?C# List.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WebApplication1.List的用法示例。


在下文中一共展示了List.Contains方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetWords

           public static void SetWords()
            {
                words= new List<string>();

            string[] splitter = { ",","\n","\r" };
           
            int i = 0;
            string[] kwords = new string[140];

            Journal[] j=DataManager.GetJournalData();

            foreach(Journal journal in j)
            {
                
                kwords[i] = journal.Keywords;
                i++;
            
            }
           

                foreach(string tword in kwords)
                {
                    string[] tempKeywords = tword.Split(splitter, StringSplitOptions.RemoveEmptyEntries);

                    foreach (string keyword in tempKeywords)
                    {
                        string temp = keyword;
                        temp = temp.TrimEnd();
                        temp = temp.TrimStart();
                        temp = temp.Replace("(", " ");
                        temp = temp.Replace(")", " ");
                        temp = temp.Replace("'", "");
                        temp = temp.Replace("\n", "");
                        temp = temp.Replace("\r", "");
                        temp = temp.Replace("\\", "");
                        temp = temp.Replace("/", ",");
                        temp = temp.Replace(" ", "-");
                        temp = temp.ToLower();

                        if (words.Contains(temp))
                        { }
                        else
                        {
                           
                            words.Add(temp);
                        }
                    }
                }

               
            }
开发者ID:talhahasanzia,项目名称:Journal_Classifier,代码行数:51,代码来源:Comparator.cs

示例2: matchACMCloudComputing

        public static float matchACMCloudComputing(string[] keywords)
        {
            savedDataFromACMCC = DataManager.GetData(TableNames.ACM.CloudComputing);
            float perc = 0;

            int totalKeywords = keywords.Length;
            int matched = 0;

            foreach (string word in keywords)
            {

                if (savedDataFromACMCC.Contains(word))
                    matched++;

            }

            perc = ((float)matched / (float)totalKeywords) * 100f;

            return perc;
        }
开发者ID:talhahasanzia,项目名称:JournalClassifier,代码行数:20,代码来源:Comparator.cs

示例3: matchACMArtificialIntelligence

        public static float matchACMArtificialIntelligence(string[] keywords)
        {
            savedDataFromACMAI = DataManager.GetData(TableNames.ACM.AI);
            float perc = 0;

            int totalKeywords = keywords.Length;
            int matched = 0;

            foreach (string word in keywords)
            {

                if (savedDataFromACMAI.Contains(word))
                    matched++;

            }

            perc = ((float)matched / (float)totalKeywords) * 100f;

            return perc;
        }
开发者ID:talhahasanzia,项目名称:JournalClassifier,代码行数:20,代码来源:Comparator.cs

示例4: PrepareUserKeywords

            public static string[] PrepareUserKeywords(string SampleKeywordsText)
            {
                List<string> Keywords = new List<string>();
                try
                {
                    int i=0;
                    string[] splitter = { ".", " ", ":", ",", ";", "'", "\"", "(", ")" };
                    string[] UserWords = SampleKeywordsText.Split(splitter, StringSplitOptions.RemoveEmptyEntries);


                    SetWords();

                    foreach (string uWord in UserWords)
                    {

                        foreach (string word in words)
                        {

                        if (word.Contains("-") && i<UserWords.Length-1 )
                        {
                            int k=i+1;
                            if (word.ToLower() == uWord.ToLower()+"-"+UserWords[k].ToLower())
                            {

                                Keywords.Add(word);
                                break;
                            }
                        }
                        else
                        {
                            if (word.ToLower() == uWord.ToLower())
                            {

                                Keywords.Add(word);
                                break;
                            }

                        }

                        }

                        i++;
                    }
                }
                catch (Exception es)
                { }

                List<string> newWords = new List<string>();


                foreach (string temp in Keywords)
                {

                    if (newWords.Contains(temp))
                    {

                    }
                    else
                    {

                        newWords.Add(temp);
                    
                    }
                
                }


                words = new List<string>();
                StreamReader read = new StreamReader(HttpContext.Current.Server.MapPath("~/App_Data/Words.txt"));

                string lineRead = read.ReadLine();

                while (lineRead != null)
                {

                    words.Add(lineRead);
                    try
                    {
                        lineRead = read.ReadLine();
                    }
                    catch (NullReferenceException ec)
                    {
                        break;
                    }
                }
                read.Close();
                read.Dispose();


                foreach (string word in words)
                {

                    if (newWords.Contains(word))
                    {

                        newWords.Remove(word);
                    }
                
                }

//.........这里部分代码省略.........
开发者ID:talhahasanzia,项目名称:Journal_Classifier,代码行数:101,代码来源:Comparator.cs

示例5: ProcessWords

            public static string ProcessWords(string text)
            {
                ///////////////////////// Get words list ////////////////////////////////
                StreamReader read = new StreamReader(HttpContext.Current.Server.MapPath("~/App_Data/Words.txt"));

                string lineRead = read.ReadLine();

                while (lineRead != null)
                {

                    words.Add(lineRead);
                    try
                    {
                        lineRead = read.ReadLine();
                    }
                    catch (NullReferenceException ec)
                    {
                        break;
                    }
                }
                read.Close();
                read.Dispose();
                /////////////////////////////////////////////////////////////////////////
                string[] splitter = { "," };
                string[] wordsArray = text.Split(splitter, StringSplitOptions.RemoveEmptyEntries);


                //////////////////// Check if words is /////////////////////////////////
                foreach (string word in words)
                {
                    for (int count = 0; count < wordsArray.Length; count++)
                    {
                        if (wordsArray[count].ToLower() == word.ToLower())
                            wordsArray[count] = "";




                    }


                }
                ///////////////////////////////////////////////////////////////////////



                List<string> listString = wordsArray.ToList();



                listString.RemoveAll(item => item == "");


                List<string> newWords = new List<string>();


                foreach (string word in listString)
                {


                    if (newWords.Contains(word))
                    {

                    }
                    else
                    {
                        newWords.Add(word);

                    }

                }

                text = String.Join(",", newWords.ToArray());
                return text;
            }
开发者ID:talhahasanzia,项目名称:Journal_Classifier,代码行数:75,代码来源:Comparator.cs

示例6: LogIn

        private void LogIn()
        {
            if (Text1.Value != "")
            {
                if (Text2.Value != "")
                {
                    User u = new User();

                    List<string> listOfUsers = new List<string>();

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

                    string sql = "SELECT username FROM employees";

                    NpgsqlCommand cmd = new NpgsqlCommand(sql, conn);
                    conn.Open();
                    NpgsqlDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        listOfUsers.Add(dr["username"].ToString());
                    }
                    conn.Close();

                    if (listOfUsers.Contains(Text1.Value))
                    {
                        string sql2 = "SELECT * FROM employees WHERE username='" + Text1.Value + "'";

                        NpgsqlCommand cmd2 = new NpgsqlCommand(sql2, conn);
                        conn.Open();
                        NpgsqlDataReader dr2 = cmd2.ExecuteReader();

                        while (dr2.Read())
                        {
                            u.password = dr2["password"].ToString();
                            u.employeenumber = Convert.ToInt32(dr2["employeenumber"]);
                            if (Convert.ToString(dr2["licensed"]) == "")
                            {
                                u.licensed = null;
                            }
                            else
                            {
                                u.licensed = Convert.ToBoolean(dr2["licensed"]);
                            }
                        }
                        if (u.password == Text2.Value)
                        {
                            u.password = Text2.Value;
                            u.username = Text1.Value;

                            Session["user"] = u;
                            if(u.username == "Admin")
                            {
                                Response.Redirect("~/Admin.aspx");
                            }
                            else
                            {
                                Response.Redirect("~/Formular.aspx");
                            }

                        }
                        else
                        {
                            Label1.Text = "Fel lösenord.";
                        }
                    }
                    else
                    {
                        Label1.Text = "Fel användarnamn.";
                    }
                }
                else
                {
                    Label1.Text = "Ange lösenord.";
                }
            }
            else
            {
                Label1.Text = "Ange användarnamn.";
            }
        }
开发者ID:Myrtass,项目名称:JE-Banken,代码行数:81,代码来源:Index.aspx.cs

示例7: matchSpringerTCS

        public static float matchSpringerTCS(string[] keywords)
        {
            savedDataFromSpringerTCS = DataManager.GetData(TableNames.Springer.TheoriticalComputerScience);
            float perc = 0;

            int totalKeywords = keywords.Length;
            int matched = 0;

            foreach (string word in keywords)
            {

                if (savedDataFromSpringerTCS.Contains(word))
                    matched++;

            }

            perc = ((float)matched / (float)totalKeywords) * 100f;

            return perc;
        }
开发者ID:talhahasanzia,项目名称:JournalClassifier,代码行数:20,代码来源:Comparator.cs

示例8: matchSpringerMCP

        public static float matchSpringerMCP(string[] keywords)
        {
            savedDataFromSpringerMCP = DataManager.GetData(TableNames.Springer.MathematicalAndComputationalPhysics);
            float perc = 0;

            int totalKeywords = keywords.Length;
            int matched = 0;

            foreach (string word in keywords)
            {

                if (savedDataFromSpringerMCP.Contains(word))
                    matched++;

            }

            perc = ((float)matched / (float)totalKeywords) * 100f;

            return perc;
        }
开发者ID:talhahasanzia,项目名称:JournalClassifier,代码行数:20,代码来源:Comparator.cs

示例9: matchSpringerIS

        public static float matchSpringerIS(string[] keywords)
        {
            savedDataFromSpringerIS = DataManager.GetData(TableNames.Springer.InformationSystems);
            float perc = 0;

            int totalKeywords = keywords.Length;
            int matched = 0;

            foreach (string word in keywords)
            {

                if (savedDataFromSpringerIS.Contains(word))
                    matched++;

            }

            perc = ((float)matched / (float)totalKeywords) * 100f;

            return perc;
        }
开发者ID:talhahasanzia,项目名称:JournalClassifier,代码行数:20,代码来源:Comparator.cs

示例10: matchElsevierSoftwareEngineering

        public static float matchElsevierSoftwareEngineering(string[] keywords)
        {
            savedDataFromElsevierSE = DataManager.GetData(TableNames.Elsevier.SoftwareEngineering);
            float perc = 0;

            int totalKeywords = keywords.Length;
            int matched = 0;

            foreach (string word in keywords)
            {

                if (savedDataFromElsevierSE.Contains(word))
                    matched++;

            }

            perc = ((float)matched / (float)totalKeywords) * 100f;

            return perc;
        }
开发者ID:talhahasanzia,项目名称:JournalClassifier,代码行数:20,代码来源:Comparator.cs

示例11: matchElsevierDistributedDatabase

        public static float matchElsevierDistributedDatabase(string[] keywords)
        {
            savedDataFromElsevierDDB = DataManager.GetData(TableNames.Elsevier.DistributedDatabase);
            float perc = 0;

            int totalKeywords = keywords.Length;
            int matched = 0;

            foreach (string word in keywords)
            {

                if (savedDataFromElsevierDDB.Contains(word))
                    matched++;

            }

            perc = ((float)matched / (float)totalKeywords) * 100f;

            return perc;
        }
开发者ID:talhahasanzia,项目名称:JournalClassifier,代码行数:20,代码来源:Comparator.cs

示例12: QtrClassSearch

        //searches for classes that are available this quarter that student meets requirements for
        protected List<string> QtrClassSearch()
        {
            List<string> currentClasses = new List<string>();
            List<string> needed = new List<string>();
            List<int> reqList = new List<int>();
            int count;

            if (date[1] == 3 || date[1] == 4) count = SummerN;
            else count = QtrN;

            //if you still need intro courses, you can't take any else
            if (introNeeded)
            {
                reqList = new List<int>(introReqID);
                reqList.Sort();
                foreach (int ReqID in reqList)
                {
                    //gets classes offered that have met prereqs
                    needed = ClassesOffered(ReqID);
                    while (count > 0 && needed.Count() > 0 && ReqIDNumberNeeded[ReqID] > 0)
                    {
                        string course = needed[0];
                        needed.Remove(course);
                        ReqIDClassesNeeded[ReqID].Remove(course);

                        if (!studentHistory.Contains(course) && !currentClasses.Contains(course))
                        {
                            ReqIDNumberNeeded[ReqID] = ReqIDNumberNeeded[ReqID] - 1;
                            count = count - 1;
                            currentClasses.Add(course);
                        }
                    }
                }
                if (checkIntro()) introNeeded = false;
            }
            //searches for main courses
            else
            {
                reqList = new List<int>(mainReqID);
                reqList.Sort();
                foreach (int ReqID in reqList)
                {
                    //gets classes offered that have met prereqs
                    needed = ClassesOffered(ReqID);
                    while (count > 0 && needed.Count() > 0 && ReqIDNumberNeeded[ReqID] > 0)
                    {
                        string course = needed[0];
                        needed.Remove(course);
                        ReqIDClassesNeeded[ReqID].Remove(course);

                        //if(course == "GAM 690") resultsBox.Items.Add(new ListItem("Looking at " + course + "in qtrSearch", course));

                        if (!studentHistory.Contains(course) && !currentClasses.Contains(course))
                        {
                            ReqIDNumberNeeded[ReqID] = ReqIDNumberNeeded[ReqID] - 1;
                            count = count - 1;
                            currentClasses.Add(course);
                        }
                    }
                }
            }
            //adds classes to studenthistory
            foreach (string cl in currentClasses) { studentHistory.Add(cl); }
            return currentClasses;
        }
开发者ID:timerwoolf,项目名称:WhenIfApp,代码行数:66,代码来源:Calculator.aspx.cs


注:本文中的WebApplication1.List.Contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。