0

Alright so I'm pretty new to programming in C#, and programming in general, and I decided to learn the programming language so I'm watching a youtube tutorial and writing everything in the same way as the guy in the video.

The only issue is that when I debug, I'm missing a few lines in the debug window. I wrote 4 Console.WriteLine commands yet it only shows 2 of them in the debug window.

Example (current and expected):

https://gyazo.com/d363af46a05b804b65a927e9b075b6e4 (What I get when I debug) https://gyazo.com/3fd4eed9d68983304b5098c9f07f809a (What I should be getting)

This might be a very popular issue that has been solved many times, but I haven't been able to find it since I don't know what to type specifically to find the solution to my problem.

I hope someone can help me. And again, the reason why the title of the question isn't specific is because I don't really know what I'm talking about so I'm relying on the images being enough.

The Code (has been moved from a comment of the author)

using System;
namespace Basics {
  class Program {
    static void Main(string[] args) {
      string characterName = ("John");
      int characterAge;
      characterAge = 35;
      Console.WriteLine("There one was a man named " + characterName);
      Console.WriteLine("He was " + characterAge + " years old.");
      Console.WriteLine("He really liked the name " + characterName);
      Console.WriteLine("But didn't like being " + characterAge);
      Console.ReadLine();
    }
  }
}
Useme Alehosaini
  • 2,998
  • 6
  • 18
  • 26
Bilereza
  • 9
  • 1
  • 1
    Please include the code that you tried – Useme Alehosaini Dec 21 '20 at 23:12
  • Does this answer your question? [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Jawad Dec 21 '20 at 23:25
  • Please, include a screenshot of the `Layout` tab of your command prompt properties (click on the top left, properties, go to Layout tab) - make sure this is the **exact same command prompt shown in your screenshot, not some other random command prompt**. Then make the console window bigger and include a screenshot of the window and the Layout tab again. You _could_ see what you are seeing with very specific settings on that Layout tab (although how you got into that state, not sure). – mjwills Dec 22 '20 at 00:20
  • Why is your command prompt configured with such a small height? – mjwills Dec 22 '20 at 00:29
  • Also, change all of the `He` references to `She` in your code. When you run the code what is shown (He or She)? – mjwills Dec 22 '20 at 00:30
  • @mjwills I've installed Visual Studio 2019 today and it's been like that since the beginning. So I have to make it bigger to see my results. I haven't changed anything in the options so I don't know why my results look like that. – Bilereza Dec 22 '20 at 00:31
  • @mjwills I changed all of the "He" references to "She" and this is the result: https://gyazo.com/0e43d7fca914d66049ea82dbf04e9c1e – Bilereza Dec 22 '20 at 00:33
  • What happens if the first two lines in `Main` are `Console.WriteLine("");`? (i.e. add these _before_ your existing `Console.WriteLine` statements). – mjwills Dec 22 '20 at 00:37
  • @mywills The same thing: https://gyazo.com/2936885dadba63f1859660e23b19e774 – Bilereza Dec 22 '20 at 00:40
  • He's running Core, not Framework. Does a Core console app use the normal Windows CMD console, or does it use a different one? – Flydog57 Dec 22 '20 at 01:08
  • `Please, include a screenshot of` @Bilereza Someone removed those comments, alas. So please add those screenshots to the question (i.e. `edit` it) not as comments. – mjwills Dec 22 '20 at 01:12
  • I'm using Visual Studio 2019 with default settings and I'm following a tutorial about making Console Applications. Sadly, I'm still very new to programming so I don't understand some of the terms you are using. I've also removed some of my past comments so the discussion in the comments wouldn't be too long. – Bilereza Dec 22 '20 at 07:10
  • Please update your question to show screenshots of the Layout tab. – mjwills Dec 22 '20 at 07:31

2 Answers2

-1

I have ran your code and it compiles fine. All four lines print.

You can try going to the solution explorer panel on the right -> right click your solution, -> Clean -> Rebuild. Then re-compile

kryz
  • 79
  • 11
-2

Long time i work whit console..

But it pretty much working c# 8.0

namespace Basics
{
    static class Program
    {
        static void Main() => ("John", 35).Story();
        static void Story(this (string CharacterName, int CharacterAge) Infomation) {
            Console.WriteLine("There one was a man named {0}", Infomation.CharacterName);
            Console.WriteLine("He was {0} years old.",Infomation.CharacterAge);
            Console.WriteLine("He really liked the name {0}", Infomation.CharacterName);
            Console.WriteLine("But didn't like being {0}", Infomation.CharacterAge);
           
        }
    }
}