C# tips and tricks 5 - Difference between const, readonly and static variables
HTML-код
- Опубликовано: 8 сен 2024
- 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
Asp.net MVC
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.
Great clarify 🎉
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.
Great
Thank you Narendar for watching this video and commenting.
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.
Hi Sir,
Please make video on difference between Finalize vs Dispose in C# (with program)
Clear explanation.
Glad you liked it. Please subscribe to our channel and share the video link in your circle. Thank you
Thank you gud explanation
You are welcome. Thank you for watching this video. Don't forget to *_like , subscribe_* and hit that *_notification_* bell 🔔. And also share this video in your circle via *WhatsApp* , *Facebook* and *Twitter* . Link to subscribe the channel goo.gl/hFueBi
Thank you so much. It was a great explanation
Thank you for watching and commenting Sanah.
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.
sir plz plz plz make more videos on scraping and crawling..you explain very well...
Thank you for your comment. I will try to upload more videos on web scrapping and crawling. Make sure you subscribe to our channel and share the videos. By the way nice name "James bond".
Have you viewed ruclips.net/video/x0qUXduMmAQ/видео.html video?
thank you sir ..i will wait for those videos...
THANK YOU perfect explanation
Thank you for watching this video and commenting. 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. Link to subscribe the channel goo.gl/hFueBi
Thank you for the explanation!
Thank you for watching and commenting. Please *subscribe* to our channel and share the video link in your circle via whatsapp, facebook and twitter.
For static variables memory is allocated at complie time.
Memory for static variables in allocated the moment you use the class where static variable is present.
And the variable will last until program terminates.
Thanks 🙏
Thank you for watching this video and commenting.
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. Link to subscribe the channel goo.gl/hFueBi
Tank youuuuu
Thank you for watching this video and commenting.
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. Link to subscribe the channel goo.gl/hFueBi
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 .
It is possible to change the readonly variable in any constructor. It will assign the values what you are assigning. It does not matter whether the constructor is paramerised or not.
I misunderstand InshaAllah, when u say Initialize 😄❤️
Sorry for that.
Thank you for watching this video. Don't forget to *_like , subscribe_* and hit that *_notification_* bell 🔔. And also share this video in your circle via *WhatsApp* , *Facebook* and *Twitter* . Link to subscribe the channel goo.gl/hFueBi
Hello bro can you java code decode
Thanks for watching and commenting the video. Subscribe to our channel and share the video in your circle via whatsapp, facebook and twitter.
You can find Java videos in below playlist,
ruclips.net/video/T9FVRmRaAvI/видео.html
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.
It is initialized or initialize not "Insallah". Thank you for your comment. Please do subscribe to our channel. And share this video in facebook, whatsapp and twitter.
lolz, same here, when i listened carefully again then i understood that he saying initialize not inshallah... but very helpful video, i have searched many videos for static variable meaning, every video tells that how to use, but not tell why to use, now in this video , his video also tells y to use static variable...
'right' is not pronounced as 'rrrrright'... so annoying
Great
Thank you for watching this video. Don't forget to *_like , subscribe_* and hit that *_notification_* bell 🔔
Continue watching the *_C# tips and tricks_* playlist for more such videos.