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

Комментарии • 38

  • @krishj8011
    @krishj8011 Месяц назад

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

  • @ahmadammouneh3061
    @ahmadammouneh3061 2 месяца назад

    Great clarify 🎉

  • @AnkproTraining
    @AnkproTraining  4 года назад

    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.

  • @narendarsingh4672
    @narendarsingh4672 4 года назад +1

    Great

    • @AnkproTraining
      @AnkproTraining  4 года назад

      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.

  • @anjaneya1badrinadh
    @anjaneya1badrinadh 4 года назад +1

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

  • @FunAndCreativeCorner
    @FunAndCreativeCorner Год назад +1

    Clear explanation.

    • @AnkproTraining
      @AnkproTraining  Год назад

      Glad you liked it. Please subscribe to our channel and share the video link in your circle. Thank you

  • @jessy4306
    @jessy4306 2 года назад +1

    Thank you gud explanation

    • @AnkproTraining
      @AnkproTraining  2 года назад

      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

  • @shaikhsanah3087
    @shaikhsanah3087 4 года назад +1

    Thank you so much. It was a great explanation

    • @AnkproTraining
      @AnkproTraining  4 года назад

      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.

  • @jigsaw7960
    @jigsaw7960 6 лет назад +2

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

    • @AnkproTraining
      @AnkproTraining  6 лет назад

      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".

    • @AnkproTraining
      @AnkproTraining  6 лет назад

      Have you viewed ruclips.net/video/x0qUXduMmAQ/видео.html video?

    • @jigsaw7960
      @jigsaw7960 6 лет назад

      thank you sir ..i will wait for those videos...

  • @BaconEggsRL
    @BaconEggsRL 3 года назад +1

    THANK YOU perfect explanation

    • @AnkproTraining
      @AnkproTraining  3 года назад

      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

  • @abduvosidmalikov
    @abduvosidmalikov 5 лет назад +1

    Thank you for the explanation!

    • @AnkproTraining
      @AnkproTraining  5 лет назад

      Thank you for watching and commenting. Please *subscribe* to our channel and share the video link in your circle via whatsapp, facebook and twitter.

  • @maheswark2322
    @maheswark2322 6 лет назад +3

    For static variables memory is allocated at complie time.

    • @AnkproTraining
      @AnkproTraining  6 лет назад +3

      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.

  • @narendarsingh4672
    @narendarsingh4672 3 года назад +1

    Thanks 🙏

    • @AnkproTraining
      @AnkproTraining  3 года назад

      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

  • @desimultimedia
    @desimultimedia 3 года назад +1

    Tank youuuuu

    • @AnkproTraining
      @AnkproTraining  3 года назад

      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

  • @sagarmalunjkar9944
    @sagarmalunjkar9944 5 лет назад +1

    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 .

    • @AnkproTraining
      @AnkproTraining  5 лет назад

      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.

  • @usama3232
    @usama3232 2 года назад

    I misunderstand InshaAllah, when u say Initialize 😄❤️

    • @AnkproTraining
      @AnkproTraining  2 года назад

      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

  • @NitishKumar-ti8ri
    @NitishKumar-ti8ri 4 года назад +1

    Hello bro can you java code decode

    • @AnkproTraining
      @AnkproTraining  4 года назад

      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

  • @devloperuniversal845
    @devloperuniversal845 5 лет назад

    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.

    • @AnkproTraining
      @AnkproTraining  5 лет назад

      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.

    • @entertaingames7918
      @entertaingames7918 5 лет назад

      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...

  • @cheeesysandwich
    @cheeesysandwich Год назад

    'right' is not pronounced as 'rrrrright'... so annoying

  • @InnocentGamerOfficial
    @InnocentGamerOfficial 3 года назад +1

    Great

    • @AnkproTraining
      @AnkproTraining  3 года назад

      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.