How to make a user input that sets a string change a bool from false to true?

So, in my poking around/attempt at learning I've created a scenario where the program asks your name, your age, and then relays both those strings back to you. From there, I want to make it so it gives you a secret message if the name typed in is "Tyler." I'm trying to use a bool to detect if the [userIsTyler], because I don't know any other way, and I sort of know this. Something on the internet kinda helped but not exactly, and I've got everything figured out up to the point of getting the program to only give you the secret message if [userIsTyler] is set to true.
What I need to know is, how do I make it so when (and only when) they type "Tyler" into the string [name], the [userIsTyler] is set to true? If you need more info I can provide that to the best of my ability, and if I wrote something wrong with my question somehow I'll try to fix it. Thanks!
No description
5 Replies
devteodex
devteodex4mo ago
name == "tyler"
The Ultimate Rat
oh. my. god. I could have SWORN I tried that already. tysm, lol!
devteodex
devteodex4mo ago
np lol
oke
oke4mo ago
probably isnt that helpful, but you do not need to explicitly check the value of a boolean with boolValue == true an if statement will just check the return value of any expression, meaning you can just use:
bool myBool = false;

if (myBool) // The same as 'if (myBool == true)'
{
// Do something
}

if (!myBool) // The same as 'if (myBool == false)'
{
// Do something
}
bool myBool = false;

if (myBool) // The same as 'if (myBool == true)'
{
// Do something
}

if (!myBool) // The same as 'if (myBool == false)'
{
// Do something
}
you can also use this to assign a bool value to a variable like:
string myStr = "this is a string"

bool strIsLong = myStr.Length > 10; // Will assign the value as true because the length is greater than 10
string myStr = "this is a string"

bool strIsLong = myStr.Length > 10; // Will assign the value as true because the length is greater than 10
just some small things to make writing code faster you might have used ', which is used for char the difference is a string is a "string" of letters (just a group of them), while a char is a single letter and is denoted by single quotes rather than double a way to remember this is a char is a single character, thus will only use a single quote, but a string can be longer and will use double the quotes
The Ultimate Rat
Actually, that is pretty helpful. The less text on the screen, the easier it is to process it when I reread (and less likely to cause errors) This is also very helpful, I might have done that. I'll remember these both, so thank you! :wires: