Be the first to post for 'C# Operators & Expressions'!

If you’re reading this, there probably aren’t very many posts yet. But don’t worry, you can be the first! Either create a new post or just reply to this one to say ‘hi’.

I had written an if/else statement for this! It never occurred to me to simply put it in one print statement.
:exploding_head:

Now now I know it might be easier to do it Ben’s way but that is borderline cheating to
to me and almost incomprehensible. You’re turning a simple print output to the console window in to something that first outputs to an evaluator and then outputs that result to the console window all on one line. AAAAAAAAAAAAAAAAAA! I’ve posted my solution here which works and is longer but I definitely enjoy being able to read the code and say yes… I can see what’s logically going on here. It’s just going to take me a while to get used to this new shorthand.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Hacker : MonoBehaviour {

//string greeting = "Hello Ben";

// Use this for initialization
void Start () {

    ShowMainMenu("Hello Ben");

}

void ShowMainMenu(string greeting2) {
    //print("Hello Console");
    //Terminal.WriteLine("Hello World");
    Terminal.ClearScreen();
    Terminal.WriteLine(greeting2);
    Terminal.WriteLine("What would you like to hack in to?");
    Terminal.WriteLine("");
    Terminal.WriteLine("Press 1 for the cops");
    Terminal.WriteLine("Press 2 for the nsa");
    Terminal.WriteLine("Press 3 for the akashic record");
    Terminal.WriteLine("");
    Terminal.WriteLine("Make your choice! ");
}
void OnUserInput(string input) {
    //Terminal.WriteLine("The user typed " + input);
    //print(input);
    if (input == "1")
    {
        print("true");
    }
    else {
        print("false");
    }
}

}

Same :grin:

1 Like

Privacy & Terms