In this video, I want to talk about defining variables and initializing them.
So we have seen how to do both by doing a line like this.
Here you see string my name Dennis.
Here we have both things in one.
So we define the variable and we initialize the variable straight away.
So what does that mean.
Let's have a look at a string pet's name.
And let's say pet's name is not defined at the beginning.
It will only be defined once the user enters a value.
So what we have here is defining or setting up a variable.
Now we can initialize the variable later on, which means we can assign a value to that variable later
on.
So here I can say daisy for example, as I have a dog named Daisy initialize variable.
Now there is another thing we can do here.
And that is to override the variable so variables can be overwritten by default.
You can make sure that the variable cannot be overwritten.
But if you need to make it a constant that you cannot change afterwards, that's something we will cover
later on.
For now, it's not really going to be that important.
But let's say my pet dies and I'm very sad and Daisy is dead.
And now the pet's name that I have is going to be barky.
Okay, lack of a better name, but let's say he's a dog that barks a lot, so I'm going to call him
barky.
So here I'm overwriting the variable entry.
So if I for example use c w Console.WriteLine.
And I say something like my pet is and then I have the curly brackets and I use pet's name in here.
And we mustn't forget the dollar sign here at the beginning.
So if I run the same line here, I'm going to get a different result as to when I run the line here.
So let me also make sure that I have console dot read key so that my software doesn't close when I run
it.
And let me run it now and we will see that it first prints out hello world.
Then it says my pet is Daisy and then it says my pet is barky.
Okay, so that's something that I wanted to make sure that you understand, as we haven't covered it
specifically like this before.
So now you know how it works.
And also the terminology.
And by the way, the name here is I assign a new value okay.
So I assign a new value to my variable pet's name.
So I'd say see you in the next video.