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: 
```cs
using System.Linq; \\put this on top

return formul.All(c => c == 'C' || c == 'H');

```

This will return `true` if all characters of `formul` string are either 'C' or 'H'
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/>