C# tips and tricks 5 - Difference between const, readonly and static variables

preview_player
Показать описание
C# tips and tricks :
Difference between const, readonly and static variables

const keyword :
A variable declared as const must be assigned a value at declaration.
And we can not change its value once it is assigned.
They are implicitly static by default.
You can apply const keyword to built-in value types (byte, short, int, long, char, float, double, decimal, bool), enum, a string literal, or a reference type which can be assigned with a value null.

readonly keyword:
The value will be initialized either at declaration time or in the constructor.

 Read only values will evaluate at runtime only.

static keyword:
static variables are common to all the objects.
Each static variable is shared among all the objects of the same class.
and they do not tied to a specific object.

ankpro
ankpro training
C#
C sharp
Bangalore
Rajajinagar
Selenium
Coded UI
Mobile automation testing
Mobile testing
JQuery
JavaScript
.Net
C
C++
Components of the .Net framework
Hello World
Literal
Keywords
Variable
Data types
Operators
Branching
Loops
Arrays
Strings
Structures
Enums
Functions
Рекомендации по теме
Комментарии
Автор

this is nice video. it helped me to understand the concept.

krishj
Автор

Hi Sir,
Please make video on difference between Finalize vs Dispose in C# (with program)

anjaneyabadrinadh
Автор

For static variables memory is allocated at complie time.

maheswark
Автор

sir plz plz plz make more videos on scraping and crawling..you explain very well...

jigsaw
Автор

Thank you so much. It was a great explanation

shaikhsanah
Автор

In Case of readonly field, Suppose I have two constructors first is Default constructor as shown in your example along with that I have another constructor
with parameter. Is it possible to change the value of readonly field in that second constructor ? What will happen if I will create two objects first without parameters and second with parameters .

sagarmalunjkar
Автор

I misunderstand InshaAllah, when u say Initialize 😄❤️

usama
Автор

I do not understand why sentence end with "Insallah" repetitive. You do not need to show devotions, it's between you and God. God is giving you knowledge, so embrace the knowledge. Hope you do not mind. You are doing good job.

devloperuniversal
Автор

'right' is not pronounced as so annoying

cheeesysandwich
Автор

Thank you for watching this video. Cheers! would you mind hitting *_like_* button and *_subscribe_* to our channel!
That will be awesome. We would be grateful to you. And also share this video in your circle via whatsapp, facebook and twitter.

AnkproTraining