All right.
So let's understand what we need in order to build an addition calculator.
So the first thing we need to do is we need to get user input okay.
So we're going to look at that in this video.
The second thing that we need to understand is how to store data how to store a value.
And then the third thing will be arithmetic operations such as addition in this case.
So how to use a plus sign so to speak, to add two numbers together to do the calculation and then give
an output with the result.
And there is a little additional thing that we will need to look into.
And that is how to convert from one data type into another data type.
Now therefore we obviously need to understand what data types are okay.
So before we do anything else let's start with the first thing out of those four.
And that is how to understand how to get data input or user input.
So let's get started.
Therefore I'm creating a new project.
So you open up Visual Studio.
You go ahead and create a new project.
We select console app here once again.
And I'm going to call this one my Addition calculator okay let's click next.
Let's keep everything else the same.
Net eight we don't activate any of those.
And let's get started.
So therefore let's go ahead and get user input.
And therefore we need to use the console class once again.
So this is the console class.
You can see that here once you hover over it represents the standard input output and error streams.
For console applications this class cannot be inherited.
Okay a bunch of words that we don't understand yet, but we will cover later on.
But what is important is that this basically helps us not only for the output as we already used it
for red line, but also for the input, so we can use it in order to get input from the user by using
the read line method here.
So you see here there is this method called read line.
I can press tab and tab again and it will write the rest of the code for me.
So what is this read line?
As I said it's a method.
And a method is basically a collection of code or lines of code that will be executed once you call
the method.
So once you basically write out the method in your code to keep it very simple, we're going to see
later on how to create our own methods and how to run them ourselves.
So we're going to have full control over our applications.
But for now we're going to use one that already is existing, that is inside of this class called console.
So classes can contain a bunch of methods.
They can contain other things as well.
But for now we're going to look at methods.
So this class contains the write line method and it contains the red line method.
This one prints something out.
So let's add a comment here.
Prints out whatever is inside of the brackets.
And this one takes the user input and stores it.
So how do we store the user input from here.
Therefore we need a variable okay.
So you see here it says string question mark console red line.
The string here indicates that it returns something.
So this console red line, once it is executed it gives us as user the capability of entering something.
And whatever we enter is then going to be either stored as we're going to do it in this case, or nothing
happens with it if we don't use it.
So in order to store it we need to create a variable.
Okay.
So I'm going to put that at the beginning of this line.
I'm going to say string.
And I'm going to call this one user input is equal to console read line okay.
So what is happening here.
Basically I'm creating a variable called user input with the data type string.
The data type string is the data type that contains text.
So it represents text as a sequence of UTF 16 code units.
UTF 16 is basically just a rule set of a bunch of characters, such as all of our alphabet, the numbers,
but also special characters, including Chinese special characters, and all kinds of characters that
are used inside of our world today inside of our digital world.
So we have this variable variable with the name user input and the data type string okay.
And then strings are used for text okay.
So now this red line, if you hover over it you see it returns a string.
So it says basically what.
Ever is returned from this red line statement.
Store it inside of user input inside of this variable, which is of the same data type, not exactly
the same data type, because you see we get these curly brackets here, basically saying, hey, there
is something wrong here.
That is because of this question mark.
But talking about this question mark at this early point in the course would be way too confusing.
So we're going to leave that out for now.
But basically what this allows us to do now is to, let's say, print out whatever the user input was.
So what I'm going to do is you entered plus user input and then I finish with a semicolon.
So we're using console dot write line.
So we're using this write line method.
As we said we used it with Hello World.
And then inside of the brackets inside of the quotations I say you entered then an empty space.
And then I have this plus which basically is adding two strings together, which basically just means
we are creating a bigger string.
We're creating a bigger text, so to speak, a longer sentence if you wish.
And then we display whatever the user input was.
So in order to keep our console awake and not close directly after this line, I'm going to say read
key here as well, which is going to basically just wait for us to press any key before closing the
console.
So instead of saying hello World here at the top, I'm going to say enter something.
Okay, let's run this and then we will see that it says enter something.
So I'm going to say hi there.
And I press enter.
And you see it says you entered.
Hi there.
So let's look at what happened here.
Basically whatever we entered after we were asked by our system with this red line.
So here this is just something where we help ourselves or the user who uses our console application
to understand what we want from him or her.
And then we have this red line statement which awaits user input, whatever is entered at that point,
we're storing it inside of our variable user input of the type string, which is the data type that
is used for text.
And then we print it out using something called concatenation.
String concatenation.
Basically here we are adding two strings together and writing them onto the console.
Okay.
So that's pretty much what we did in this video.
So now you know how you can use user input.
And you learned about one data type called string.
We're going to see other data types in the next few videos because whenever we want to do calculations.
So for example addition we need to make sure that we understand numbers as well.
So I'd say see you in the next video.