Intro
Hey all, hope you are doing great. I am going to have some fun by teach C#. what I am going exactly to do is, when ever I get a free time I will post something. most of my tutorial lessons will be based on topics for example: variables, exception, classes, inheritance. If you have a hope work and you want me to help you. please don't post any code, only tell me what you understand what you don't understand and I will try to bring you up to date.
blessings
:icon_cheesygrin:

Ok, to understand variables is easy. let us say you are a manager of the hotel. and in your hotel you have 10 rooms. each room can host two persons.

early in the morning a person came and want to rent a room for three nights. then you "the manager" give him/her room number 1.

so now the hotel is half room less than before. in stead of 10 rooms we have only 9 and half rooms are free.

the person who rent the room is a variable.
the hotel is the memory.

ok. I am going to demonstrate it in C# code:

int intVariable;
string strVariable;
double dblVariable;

These are some of the variables.
the first word I typed such as int, string, double are giving a personality to a variable. we are telling to the computer hey, intVariable should be type integer, strVariable should be type string, dblVariable should be type double.

Note: if in case you noticed that under one of the variables a green line this means that the variable is not in use yet. so you have to use it or put it in freeze by typing two forward slashes in front of the variable sentence.

Now ask your self, how can I use this variable?

I am going to submit another lesson and explain how to use variables.

Blessings

Ok, to use a variables is very easy.
1- label or textBox or even listBox
2- one of the above = the variable;

The example:

int intVariable = 777;

textbox1.Text = intVariable;

Note: the above line is going to warn you that intVariable is not a string. there are many ways to solve this problem and two of it are:

Please change the above variable to:

Convert.ToString(intVariable);

or

intVariable.ToString();

and then use what ever object you want such as:

textBox.Text = Convert.ToString(intVariable);

or

textBox.Text = intVariable.ToString();

Blessings

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.