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

Поділитися
Вставка
  • Опубліковано 16 тра 2017
  • 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

КОМЕНТАРІ • 37

  • @ahmadammouneh3061
    @ahmadammouneh3061 19 днів тому

    Great clarify 🎉

  • @anjaneya1badrinadh
    @anjaneya1badrinadh 4 роки тому +1

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

  • @abduvosidmalikov
    @abduvosidmalikov 4 роки тому +1

    Thank you for the explanation!

    • @AnkproTraining
      @AnkproTraining  4 роки тому

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

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

  • @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

  • @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 ua-cam.com/video/x0qUXduMmAQ/v-deo.html video?

    • @jigsaw7960
      @jigsaw7960 6 років тому

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

  • @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

  • @AnkproTraining
    @AnkproTraining  3 роки тому

    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.

  • @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

    Great

    • @AnkproTraining
      @AnkproTraining  3 роки тому

      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.

  • @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

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

  • @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

  • @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,
      ua-cam.com/video/T9FVRmRaAvI/v-deo.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 2 роки тому +1

    Great

    • @AnkproTraining
      @AnkproTraining  2 роки тому

      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.