DarkRoomW.frmMain.Statistics C# (CSharp) Method

Statistics() public method

public Statistics ( int stat ) : int
stat int
return int
        public int Statistics(int stat)
        {
            int statistic = 0;

            switch (stat)
            {
                case 0: // word count
                    statistic = new Regex(@"\s+").Replace(txtPage.Text.Trim()," ").Split(' ').Length;
                    break;
                case 1: // characters - no spaces
                    statistic = txtPage.Text.Replace(" ", "").Length;
                    break;
                case 2: // charactesr - w/ spaces
                    statistic = txtPage.Text.Length;
                    break;
                case 3: // lines
                    statistic = txtPage.Lines.Length;
                    break;
            }

            return statistic;
        }

Usage Example

コード例 #1
0
 private void frmStatistics_Load(object sender, EventArgs e)
 {
     lblWords.Text        = parent.Statistics(0).ToString();
     lblCharNoSpaces.Text = parent.Statistics(1).ToString();
     lblCharSpaces.Text   = parent.Statistics(2).ToString();
     lblLines.Text        = parent.Statistics(3).ToString();
 }