FAQ: String, The Exception - Strings can be Null or Empty or Unassigned

This community-built FAQ covers the " Strings can be Null or Empty or Unassigned" exercise from the lesson “String, The Exception”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn C#

FAQs on the exercise _ Strings can be Null or Empty or Unassigned_

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!
You can also find further discussion and get answers to your questions over in Language Help.

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head to Language Help and Tips and Resources. If you are wanting feedback or inspiration for a project, check out Projects.

Looking for motivation to keep learning? Join our wider discussions in Community

Learn more about how to use this guide.

Found a bug? Report it online, or post in Bug Reporting

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Why does this exercise make me use {} in the if and else statement if they’re just one line of code each one? Isn’t just skipping the curly brackets possible if there is only one line of if statement?

using System;

namespace StringTheException
{
class Program
{
static void Main(string args)
{
Console.Write("Please input: ");
string input = Console.ReadLine();
if (String.IsNullOrEmpty(input)){
Console.WriteLine(“You didn’t enter anything!”);
}
else{
Console.WriteLine(“Thank you for your submission!”);
}

}

}
}

When I try to run this I get a huge error for some reason. I can’t see any difference between what I did and the solution the lesson gives. Can someone help me?

System.IO.FileNotFoundException: Unable to find the specified file.
at Interop.Sys.GetCwdHelper(Byte* ptr, Int32 bufferSize)
at Interop.Sys.GetCwd()
at System.Environment.get_CurrentDirectory()
at System.IO.Directory.GetCurrentDirectory()
at Microsoft.DotNet.Tools.Run.RunCommand.Initialize()
at Microsoft.DotNet.Tools.Run.RunCommand.Execute()
at Microsoft.DotNet.Tools.Run.RunCommand.Run(String args)
at Microsoft.DotNet.Cli.Program.ProcessArgs(String args, ITelemetry telemetryClient)
at Microsoft.DotNet.Cli.Program.Main(String args)

Have you tried resetting the exercise and/or changing browser?

If resetting exercise and/or changing browser doesn’t work, then:

If you type ls in the terminal, what do you see?

If you click the folder icon (upper left corner of editor) and select StringTheException.csproj, what TargetFramework do you see?

If you want to enter properly formatted code in the forum posts, you can click the </> button and then paste your code on a new line between the pair of three backticks.

```
Paste code between the backticks on new line
```