Declare variables

A literal is literally a hard-coded value. Hard-coded values are values that are constant and unchanged throughout the execution of the program. However, most applications will require you to work with values that you don’t know much about ahead of time. In other words, you’ll need to work with data that comes from users, from files, or from across the network.

When you need to work with data that isn’t hard-coded, you’ll declare a variable.

What is a variable?

variable is a container for storing a type of value. Variables are important because their values can change, or vary, throughout the execution of a program. Variables can be assigned, read, and changed. You use variables to store values that you intend to use in your code.

A variable name is a human-friendly label that the compiler assigns to a memory address. When you want to store or change a value in that memory address, or whenever you want to retrieve the stored value, you just use the variable name you created.

Declare a variable

To create a new variable, you must first declare the data type of the variable, and then give it a name.

C#Copy

string firstName;

In this case, you’re creating a new variable of type string called firstName. From now on, this variable can only hold string values.

You can choose any name as long as it adheres to a few C# syntax rules for naming variables.

networking training courses malaysia

Leave a Reply

Your email address will not be published. Required fields are marked *