Check character from input count occurance in String

Rainier laan

I'm trying to count the occurrence of a single digit to that in a string. What I mean by this is The user types in a sentence in a multi line TextBox and below in a separate text field a single letter. I need to check how many times that single letter occurs in the sentence.

Currently, I have the input of the two text fields by using this

string InputSingleline = SingleLineTxtBox.Text;
string InputMultiline = MultiLineTxtBox.Text;

And I'm trying to count the occurance of input in InputSingleLine in MultiLineTxtBox by using this but it does not work.

int Count = InputMultiline.Count(f => f == SingleLineTxtBox);
Salah Akbari

Firstly you should count the occurrences of InputSingleline instead of SingleLineTxtBox since you have already set the InputSingleline to SingleLineTxtBox.Text. And secondly the InputSingleline is a string with one character, so you need to use something like FirstOrDefault to return that character from this string:

int Count = InputMultiline.Count(f => f == InputSingleline.FirstOrDefault());

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Count occurance of a string and sum the next comma value from a large file

SQL Group by Count String occurance

How to replace the n th occurance of a character in a String ?

replacing only the first occurance of a character in string

Find character occurance percentage from a List of words

Match last occurance of a character in a string only if it appears multiple times in that string

Remove only the last occurance of the words from string

replacing all occurance of a substring from a string in java

Remove first occurance of <p> from string

python string, delete character, count from right

How to count character and line from a string in assembly?

how to extract string in R up to the first (and not to the last) occurance of a character?

how to find the first repeated occurance of the character inside the same string in c

Split string and repeat xml tag based on nth occurance of special character

Check if string contains a character from list - Typescript

Check that string contains a character from set of characters

Unable to search character with string input from fgets

How do I count the occurance of a string per file in a directory?

How to compare and get count of coulmn value occurance from multiple dataframes

how to get count total occurance from different tables in Mysql

How display numbers from the first column and count the number of occurance?

Select2 dropdown on search checking any character occurance, need to change to only check by first character

Count number of character occurrences from input text file

Mongo occurance count by column

How to count occurance in livecode?

Is there any way to check character input from a readline is a number?

Check data type from string input in JavaScript

Character count of Unicode string

Count specific character in a string

TOP Ranking

HotTag

Archive