csharp count specific words in string

Code Example - csharp count specific words in string

                
                        var count = this.GridView1.Rows.Cast<DataGridViewRow>()
             .Count(row => row.Cells["PresentAbsent"].Value == "Present");

            this.lblPresent.Text = count.ToString();
                    
                
 

csharp count number of occurrences in string

                        
                                char myChar = 'x';
string myString = "xyz";

int count = myString.Count(s => s == myChar);