Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# count number of occurrences in string

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

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

count number of specific characters in string c#

# cCopyusing System;
using System.Linq;

namespace get_first_char_of_string
{
    class Program
    {
        static void Main(string[] args)
        {
            string source = "/once/upon/a/time/";
            int count = source.Split('o').Length - 1; 
            Console.WriteLine(count);
        }
    }
}
Comment

count number of specific characters in string c#

string source = "/once/upon/a/time/";
int count = 0;
foreach (char c in source) 
  if (c == '/') count++;
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to set window position 
Csharp :: eleventy set default layout 
Csharp :: convert array to datatable c# 
Csharp :: .net framework cheat sheet 
Csharp :: unity screentoworldpoint 
Csharp :: c# int array add number 
Csharp :: c# hashset 
Csharp :: palindromes 
Csharp :: c# string contain double quote 
Csharp :: change text color wpf 
Csharp :: c# loop array back 
Csharp :: ocr library for c# 
Csharp :: how to add default value to combobox in wpf 
Csharp :: it solutions 
Csharp :: why doesnt the if command work in C# 
Csharp :: function on program stops unity 
Csharp :: embed video to exe file with c# 
Csharp :: syoutube 
Html :: html yen symbol 
Html :: html disable editing textbox 
Html :: bootstrap css cdn 
Html :: how to remove suggestions from input field 
Html :: success green color code 
Html :: html facebook meta tags 
Html :: whatsapp message html a tag 
Html :: html shell 
Html :: html display only on mobile 
Html :: font awesome 
Html :: abrir pdf con html 
Html :: how to open in new page link html 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =