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


C# List.ToArray方法代码示例

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


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

示例1: LinkButton1_Click

        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            char[] trimmer={' '};

            List<string> keywords = TextBox2.Text.Split(',').ToList();

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

            foreach (string word in keywords)
            {

                string temp = word.ToLower();
                temp = temp.TrimEnd(trimmer);
                temp = temp.TrimStart(trimmer);
                filteredKeywords.Add(temp);

            }
            float CSMatch = Comparator.matchSpringerCS(filteredKeywords.ToArray());
            float ENMatch = Comparator.matchSpringerEngineering(filteredKeywords.ToArray());
            float MAMatch = Comparator.matchSpringerMA(filteredKeywords.ToArray());

            SCS.Text = " Computer Science: " +CSMatch  + "%";
            SEN.Text = " Engineering: " + ENMatch + "%";
            SMA.Text = " Mathematics: " + MAMatch + "%";
            ; ;
        }
开发者ID:talhahasanzia,项目名称:JournalClassifier,代码行数:26,代码来源:Main.aspx.cs

示例2: GetSeriesString

        private string GetSeriesString()
        {
            List<Expense> expenses = Expense.GetAmountRandomAmountList();

            List<string> expensesLinePoints = new List<string>();
            StringBuilder seriesString = new StringBuilder();

            foreach (Expense expenseItem in expenses)
            {
                expensesLinePoints.Add(expenseItem.Amount.ToString());

                if (expenseItem.Date.Month == 12)
                {
                    if (seriesString.Length > 0)
                    {
                        seriesString.Append(",");
                    }
                    seriesString.Append("{ ");
                    seriesString.AppendFormat(@"name: {0},
                            data: [{1}]", expenseItem.Date.Year, string.Join(",", expensesLinePoints.ToArray()));
                    seriesString.Append("  }");

                    expensesLinePoints = new List<string>();
                }
            }

            return seriesString.ToString();
        }
开发者ID:sanyaade-fintechnology,项目名称:NinjaTrader,代码行数:28,代码来源:Original.aspx.cs

示例3: PrepareUserKeywords


//.........这里部分代码省略.........
                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);
                    }
                
                }

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

示例4: 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

示例5: PlotSingle

        //Method called to plot the points on a single line graph
        public void PlotSingle(List<int> l1, List<int> l1Year)
        {
            // ChartFormat();
            //One series on one chart
            Series series1 = Chart.Series["Series1"];

            //totals for getting average
            double total1 = 0;

            //growth rate variables
            double growthRate1 = 0;
            double averageGrowthRate1 = 0;

            int[] list1 = l1.ToArray();
            int[] curYear = l1Year.ToArray();
            int yearIncrementer = -1;

            foreach (int plot in l1)
            {
                yearIncrementer++;
                Chart.Series["Series1"]
                    .Points.AddXY(curYear[yearIncrementer], list1[yearIncrementer]);

                total1 += list1[yearIncrementer];

                //check no nulls are taken for the growth rate formula
                if ((yearIncrementer - 1 >= 0))
                {
                    growthRate1 = (double)((list1[yearIncrementer] - list1[yearIncrementer - 1]) / (double)list1[yearIncrementer - 1]);
                }

                //total growth rate variables first
                averageGrowthRate1 += growthRate1;
            }

            //get average and convert to percent
            averageGrowthRate1 = (averageGrowthRate1 / list1.Length) * 100;

            //Average values for each series
            double seriesAverage1 = (double)total1 / (double)list1.Length;

            //Create DataTable to insert all these values into Gridview
            DataTable dt = new DataTable();
            dt.Clear();
            dt.Columns.Add("Series Name");
            dt.Columns.Add("Sample Size");
            dt.Columns.Add("Overall Average");
            dt.Columns.Add("Growth Rate");
            DataRow row1 = dt.NewRow();
            row1["Series Name"] = series1Name;
            row1["Sample Size"] = list1.Length.ToString();
            row1["Overall Average"] = Math.Round(seriesAverage1).ToString();
            row1["Growth Rate"] = Math.Round(averageGrowthRate1, 2).ToString() + "%";
            dt.Rows.Add(row1);

            //Bind these values to the gridview
            GridView1.DataSource = dt;
            GridView1.DataBind();
            ChartFormat();
        }
开发者ID:afitzy111,项目名称:ComparisonData,代码行数:61,代码来源:About.aspx.cs

示例6: PlotMultiple

        //Method called to plot the points on a 2 line graph
        public void PlotMultiple(List<int> l1, List<int> l2, List<int> l1Year, List<int> l2Year)
        {
            //ChartFormat();
            //Two series on one chart
            Series series1 = Chart.Series["Series1"];
            Series series2 = Chart.Series["Series2"];

            //totals for getting average
            double total1 = 0, total2 = 0;

            //growth rate variables
            double growthRate1 = 0, growthRate2 = 0;
            double averageGrowthRate1 = 0, averageGrowthRate2 = 0;

            int[] list1 = l1.ToArray();
            int[] list2 = l2.ToArray();
            int[] curYear = l1Year.ToArray();
            int[] curYear2 = l2Year.ToArray();
            int yearIncrementer = -1;

            foreach (int plot in l1)
            {
                yearIncrementer++;
                Chart.Series["Series1"]
                    .Points.AddXY(curYear[yearIncrementer], list1[yearIncrementer]);

                total1 += list1[yearIncrementer];

                //check no nulls are taken for the growth rate formula
                if ((yearIncrementer - 1 >= 0))
                {
                    growthRate1 = (double)((list1[yearIncrementer] - list1[yearIncrementer - 1]) / (double)list1[yearIncrementer - 1]);
                }

                //total growth rate variables first
                averageGrowthRate1 += growthRate1;
            }

            yearIncrementer = -1;

            foreach (int plot in l2)
            {
                yearIncrementer++;
                Chart.Series["Series2"].Points.AddXY(curYear2[yearIncrementer], list2[yearIncrementer]);

                total2 += list2[yearIncrementer];

                //check no nulls are taken for the growth rate formula
                if ((yearIncrementer - 1 >= 0))
                {
                    growthRate2 = (double)((list2[yearIncrementer] - list2[yearIncrementer - 1]) / (double)list2[yearIncrementer - 1]);
                }
                averageGrowthRate2 += growthRate2;

            }

            //get average and convert to percent
            averageGrowthRate1 = (averageGrowthRate1 / (double)list1.Length) * 100;
            averageGrowthRate2 = (averageGrowthRate2 / (double)list2.Length) * 100;

            //Average values for each series
            double seriesAverage1 = (double)total1 / (double)list1.Length;
            double seriesAverage2 = (double)total2 / (double)list2.Length;

            //Spearman's Rank correlation for each random set of integers
            double spearmansRankValue = SpearmansCoeff(list1, list2);

            //Calculates the Degrees of Freedom needed to test for significance
            //in the final version, this value will be the number of points - 2
            //i.e. DoF = n - 2;
            double DoF = DegreesOfFreedom(list1, list2);

            string isSignificant;

            if (SignificanceTest(DoF, spearmansRankValue))
            {
                isSignificant = "There is at least a 95% chance that the relationship between these two datasets are significant";
            }
            else
            {
                isSignificant = "It is not certain that the relationship between these two datasets are statistically significant";
            }

            //Create DataTable to insert all these values into Gridview
            DataTable dt = new DataTable();
            dt.Clear();
            dt.Columns.Add("Series Name");
            dt.Columns.Add("Sample Size");
            dt.Columns.Add("Overall Average");
            dt.Columns.Add("Growth Rate");
            dt.Columns.Add("Spearman's Rank Correlation and Significance");
            DataRow row1 = dt.NewRow();
            row1["Series Name"] = series1Name;
            row1["Sample Size"] = list1.Length.ToString();
            row1["Overall Average"] = Math.Round(seriesAverage1).ToString();
            row1["Growth Rate"] = Math.Round(averageGrowthRate1, 2).ToString() + "%";
            row1["Spearman's Rank Correlation and Significance"] = "Correlation: " + Math.Round(spearmansRankValue, 2).ToString() + ".  " + CorrelationTest(spearmansRankValue);
            dt.Rows.Add(row1);
            DataRow row2 = dt.NewRow();
//.........这里部分代码省略.........
开发者ID:afitzy111,项目名称:ComparisonData,代码行数:101,代码来源:About.aspx.cs

示例7: Keywords

        public static string Keywords(string uri, string tagAttribute, string tagValue)
        {





            List<string> keywordsList = new List<string>();
            HtmlDocument doc = new HtmlDocument();

            try
            {
                doc.LoadHtml(new WebClient().DownloadString(uri));


                var rootNode = doc.DocumentNode;

                if (tagAttribute == "Tag")
                {

                    var data = rootNode.Descendants(tagValue);
                    foreach (var dataNode in data)
                    {


                        string dataString = dataNode.InnerText;
                        dataString += " " + dataNode.InnerHtml;
                        keywordsList.Add(dataString);

                    }
                }
                else
                {


                    var data = rootNode.Descendants().Where(n => n.GetAttributeValue(tagAttribute, "").Equals(tagValue));
                    foreach (var dataNode in data)
                    {


                        string dataString = dataNode.InnerText;
                        dataString += " " + dataNode.InnerHtml;
                        keywordsList.Add(dataString);

                    }
                
                }



                

            }
            catch (Exception ex)
            {



            }
            string Keywords = String.Join(", ", keywordsList.ToArray());






            return Keywords;
        
        
        
        
        }
开发者ID:talhahasanzia,项目名称:Journal_Classifier,代码行数:72,代码来源:Crawler.cs

示例8: CriarComando

        private static OracleCommand CriarComando(String cmmdText, CommandType cmmdType, List<OracleParameter> listParameter)
        {
            try
            {
                var conn = new OracleConnection();
                conn.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["ConnectionStringOracleDesenv"].ConnectionString;
                OracleCommand cmd = conn.CreateCommand();
                cmd.CommandText = cmmdText;
                cmd.CommandType = cmmdType;

                if (listParameter != null)
                {
                    cmd.BindByName = true;
                    cmd.Parameters.AddRange(listParameter.ToArray());
                }
                // Retorna o comando criado
                return cmd;
            }
            catch (DbException ex)
            {
                throw ex;
            }
        }
开发者ID:carlaofernandesedu,项目名称:suporteinternoci,代码行数:23,代码来源:DataAccessObject.cs

示例9: FromSpringer

        public static Journal[] FromSpringer()
        {

            List<Journal> JournalsFromSpringer = new List<Journal>();

            string source = "https://www.springer.com/gp/adis/products-services";
            var html = new HtmlDocument();

            try
            {
                html.LoadHtml(new WebClient().DownloadString(source)); // load a string web address
                // create a root node
                var root = html.DocumentNode;

                var Links = root.Descendants().Where(n => n.GetAttributeValue("class", "").Equals("flapContent--paragraph"));


                foreach (var Link in Links)
                {


                    Journal JournalObj = new Journal();

                    HtmlAttribute newAttribute = Link.FirstChild.Attributes["href"];
                    JournalObj.Link = newAttribute.Value;
                    JournalObj.Name = Link.InnerText;
                    JournalObj.Website = "Springer";
                    //JournalObj.Keywords = KeywordExtractor.springerKeywords(JournalObj.Link);
                    //JournalObj.Submit = KeywordExtractor.springerLink(JournalObj.Link);
                    if (String.IsNullOrEmpty(JournalObj.Submit))
                    {
                        JournalObj.Submit = "https://www.editorialmanager.com/";
                    
                    }
                    JournalsFromSpringer.Add(JournalObj);


                }
            }
            catch (Exception ex)
            { 
            
            
            }
            return JournalsFromSpringer.ToArray();
        }
开发者ID:talhahasanzia,项目名称:Journal_Classifier,代码行数:46,代码来源:JournalLinks.cs

示例10: CollectPackages

        public static Package[] CollectPackages()
        {
            List<int> viewIds = new List<int>(), editIds = new List<int>(), ownIds = new List<int>();

            // [Hack]: Empty string returns all files.
            foreach (var info in SearchFileInfos(""))
            {
                var id = info.Id;

                if (IsOwnerOf(id))
                {
                    ownIds.Add(id);
                }
                else if (HasEditRights(id))
                {
                    editIds.Add(id);
                }
                else if (HasViewRights(id))
                {
                    viewIds.Add(id);
                }
                else
                {
                    throw new Exception("Leak in SearchPackages. A FileInfo to which the current user has no rights, has been retrieved.");
                }
            }

            var viewable = new Package() { Description = "Contains all viewable files.", Id = -1, Name = "Viewable Files", OwnerEmail = _sessionUser.Email, FileIds = viewIds.ToArray<int>() };
            var editable = new Package() { Description = "Contains all editable files.", Id = -2, Name = "Editable Files", OwnerEmail = _sessionUser.Email, FileIds = editIds.ToArray<int>() };
            var owned    = new Package() { Description = "Contains all owned files.",    Id = -3, Name = "Owned Files",    OwnerEmail = _sessionUser.Email, FileIds = ownIds.ToArray<int>()  };

            // [Hack]: Empty string returns all packages.
            var packs = new List<Package>(SearchPackages(""));

            packs.AddRange(new Package[] {viewable,editable,owned});

            return packs.ToArray<Package>();
        }
开发者ID:Crelde,项目名称:ClientBNDN,代码行数:38,代码来源:Controller.cs

示例11: GetPieChartSeriesString

        private string GetPieChartSeriesString()
        {
            List<Expense> expenses = Expense.GetAmountRandomAmountList();

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

            for (int index = 12; index < expenses.Count; index++)
            {
                expensesLinePoints.Add(string.Format("['{0}',{1}]",
                    expenses[index].Date.ToString("MMMM"),
                    expenses[index].Amount));

            }

            return string.Join(",", expensesLinePoints.ToArray());
        }
开发者ID:sanyaade-fintechnology,项目名称:NinjaTrader,代码行数:16,代码来源:Original.aspx.cs

示例12: CheckboxListSelections

 private string[] CheckboxListSelections(System.Web.UI.WebControls.CheckBoxList list)
 {
     List<String> values = new List<String>();
     for (int counter = 0; counter < list.Items.Count; counter++) {
         if (list.Items[counter].Selected) {
             values.Add(list.Items[counter].Value);
         }
     }
     return values.ToArray();
 }
开发者ID:Andi1986,项目名称:ChatApp,代码行数:10,代码来源:Chat.aspx.cs


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