title: Why can't I execute the Method here in C#
body: <pre class="lang-cs prettyprint-override"><code>if (titleGiven)
  {
      Console.WriteLine(&quot;Enter a title:&quot;);
      title = Console.ReadLine(); 
      Post firstPost = new Post(title, username, isPublic);
  }
  else
  {
      Post firstPost = new Post();
  }
      
  while (end)
  {
      Console.WriteLine(&quot;Do you want to check the information about the post? Yes|No&quot;);
      checkPost = Console.ReadLine(); 
      if (checkPost == &quot;yes&quot;)
      {
          firstPost.ShowInfo(); 
      }
                          
  }
  </code></pre>
  <p>So basically when I enter a title, a new object of the class Post is being made. This class has a method called ShowInfo() which displays the ID, the title, the user who posted the post etc.  So in my while I check if the user wants to check the post info, if that is the case the ShowInfo Method of the class Post should show up. But it doesn't let me use the Method, because there is no such thing as a &quot;firstPost&quot; in this context.</p>