csharp count number of occurrences in string

Code Example - csharp count number of occurrences in string

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

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

find character from string csharp count

                        
                                int count = Regex.Matches(test, "word").Count;
                            
                        
 

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();