True or False?

Hi All.

below is my code:

using System;

namespace TrueOrFalse
{
class Program
{
static void Main(string args)
{
// Do not edit these lines
Console.WriteLine(“Welcome to ‘True or False?’\nPress any key to begin:”);
string entry = Console.ReadLine();
Tools.SetUpInputStream(entry);

  string[] questions = {"True", "False","True"};
  bool[] answers = {true, false, true};
  bool[] responses = new bool[3];
  
  if (questions.Length != answers.Length)
  {
    Console.WriteLine("Warning!, Questions doesn't equal answers");
  }
  
  int askingIndex = 0;
  
  foreach (string question in questions)
  {
    string[] input = {};
    bool[] isBool = {};
    bool[] inputBool = {};
    
    Console.WriteLine($"Question 1: {questions[0]}. Please respond true or false");
    Console.ReadLine();
    string reply = Console.ReadLine();
    isBool = Boolean.TryParse(input, out inputBool);
    
  }
}

}
}

I am getting stuck on the part where it is asking me Now let’s check if the user’s input can be converted to a boolean.

Call the method Boolean.TryParse() to convert the user input to a boolean value.

This method takes two arguments: a string value to convert and a bool variable to store the converted string. It returns true if the conversion was successful, false otherwise.

there are no guides on this and would appreciate any help!

Hey @ruby4126738306

C# is a Microsoft technology, there’s always guides:
https://docs.microsoft.com/en-us/dotnet/api/system.boolean.tryparse?view=netframework-4.8

There’s even an example of how to use it in the way you’re being asked to. :slight_smile:

3 Likes