Displaying the results

Now, imagine that there are entries in both the boxes. In that case, you need to display some text. So, for example, type the following code:

Label1.Text = "Your entries have been saved";

Here, you're pretending that you're saving to a database. In real life, that's not so easy; you've got to write a lot more code. On the other hand, if one of the boxes is empty or both the boxes are empty, you have to display a relevant message. So, first you will say else, and then within a set of curly braces, you will say the following:

else{    Label1.Text = "Both entries must be specified.";}

Remember to close this with a semicolon. That's it. This is our simple program!

Now, let's add a couple of comments in simple English, starting ...

Get Beginning C# 7 Hands-On – The Core Language now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.