0

I'm trainning in C# alone for this moment, and encounter my first problem.

I use VSCode as IDE.

What I Am Try To Do

Create two functions, the first, data like name and return it. the second return full name. All in one in a class.

What I Do From Here

using System

namespace Helloworld
{
  class Program
  {
    static void Main(string[] args)
    {
      Program p = new Program();
      Console.WriteLine(p.getFullName())
    }

    public string getName(string message)
    {
      string? name;
      
      do
      {
        Console.WriteLine(message);
        name = Console.ReadLine();
      } 
      while (string.IsNullOrEmpty(firstName)); // For avoid null or empty string, I'm not found another solution.

      return name;
    }

    public string getFullName()
    {
       const string firstNameMessage = "Enter your first name: ";
       const string lastNameMessage  = "Enter yout last name: ";

       string result = $"{getName(firstNameMessage)} {getName(lastNameMessage)}"
       return result;
    }
  }
}

I Have Encountered Any Problems

1 - When I launch the command dotnet run, my program follow instructions while the first Console.WriteLine. When I type an random name in VSCode's Debug Console. Nothing happens...
My questions: Does this problem come my code ? Am I using an unsuitable IDE ? Or Am I not working with the good VSCode's Tools ?

2 - When I want restart or build I have a message like The process cannot access the file C:\Users\Username\ Documents\Work\learningCSharp\bin\Debug\net6.0\learningCSharp.dll' because it is being used by another process.
My question: How I kill process which use my DLL file ?

Reuno92
  • 57
  • 1
  • 1
  • 7
  • The build should give an error also, you have `{getName(lestNameMessage)}` and should be `{getName(lastNameMessage)}` – Camadas Aug 23 '22 at 09:38
  • Yes, I have rewrite my code. I don't have this problem on cs file. I modify now, thank you for your message. – Reuno92 Aug 23 '22 at 09:44
  • I highly recommend using full fat Visual Studio for C# development and learning, [there is a free version](https://visualstudio.microsoft.com/vs/community/). Also, no, this is not the same for all IDEs, VSCode is special in this regard. Furthermore, if you found a solution on Stack Overflow, instead of posting a new question and answer it yourself with a link to the already existing question you should just upvote the original question and answer that helped you – MindSwipe Aug 23 '22 at 09:54
  • Does this answer your question? [Debug Console window cannot accept Console.ReadLine() input during debugging](https://stackoverflow.com/questions/41195432/debug-console-window-cannot-accept-console-readline-input-during-debugging) – MindSwipe Aug 23 '22 at 09:54

1 Answers1

0

I solve all my problem finally alone. I read here the solution.

I'm posting the solution anyway.

in your launch.json replace "console": "internalConsole" by "console": "integratedTerminal.

If you are senior in C#, Can you tell us if is it same for all IDEs ?

Reuno92
  • 57
  • 1
  • 1
  • 7