Question: The input can only include two chemical elements: `C` and `H`
The program must control.
How can I provide that?

```
if (formul.Contains('C') == true && formul.Contains('H') == true)
    return true;

```

When my input is `HCA` it is still true. I want it only includes `C` and `H`.

Answer: 
Using LINQ as suggested by @Piotr is fine for something this simple, but in general it is preferable to use Regular Expressions (regexes) for text pattern matching, like this:

```
Regex.IsMatch(input, @"^[CH]+$");

```

This will return `true` if and only if `input` comprises a string of one or more characters, each being 'C' or 'H'.

You can test this here: <https://regex101.com/r/X6pzqa/1/>
Chemical formulas (as far as I know) can contain also numbers, so you have to take that into account as well, here is my idea of solving problem:

```
return ! formula.Any(ch => char.IsLetter(ch) && ch != 'C' && ch != 'H');

```

It checks wheter any letter in a formula is different from `C` or `H`. If there's letter other than `C` or `H`, it returns false, true otherwise.