Use Substring method to count specific character from a string
<p>So I am new to programming and one of my exercises involves using a substring within a loop to count the number of iterations of a specific character with a user's input.</p>

<p>As far as I can tell for the exercise, and what I know in C sharp so far, using a substring in this will only help read the position of a character within the input, and will not count it. I can not make heads or tails of this, and am at a loss.</p>

<p>I want to know how to understand this, and what ways I am missing the point of the exercise.
I need an idea of how to set the substring to read the number of a certain character type from the end-user's input from console. </p>

<p><strong>This is the original question:</strong></p>

<p>There is a method called Substring that we can use with a string to look at a portion of a string.  </p>

<p>For example, the following code will print the letter a.</p>

<pre><code>string input = "abcdef";  
Console.WriteLine(input.Substring(0, 1));
</code></pre>

<p><strong>Assignment:</strong></p>

<p>Given the following input, create a loop that uses the Substring method to count the number of times the letter ‘z’ occurs in a string input by the user.</p>

<pre><code>asdfojiaqweb;ounqwrb;ounwqen;zzzn bnaozonza
</code></pre>

<p><em>Edit: So Far I have the code to count the number of times that Z is used, but I don't know how to incorporate a substring into it</em></p>

<pre><code>int total = 0;  
var letter = new HashSet&lt;char&gt; { 'z' };
Console.WriteLine("Please enter your letters:");

// asdfojiaqweb;ounqwrb;ounwqen;zzzn bnaozonza
string sentence = Console.ReadLine().ToLower();

for (int i = 0; i &lt; sentence.Length; i++)
{
    if (letter.Contains(sentence[i]))
    {
        total++;
    }
}
Console.WriteLine("Total number of Z uses is: {0}", total);
// Console.WriteLine(sentence.Substring(0, 1));
</code></pre>