VAR vs Dynamic in C# | C# Interview Questions | CSharp Interview Questions

Поділитися
Вставка
  • Опубліковано 6 жов 2024
  • Buy our full C#,Angular,ASP.NET Interview questions with answer course from www.questpond....
    In this video we will discuss a important C# interview question var keyword vs dynamic. Many C# developers during interview say var datatype is known during compile time which sends a very wrong message to the interviewer. So this video discusses and demonstrated how VAR is compile time and how Dynamic is run time.
    See our other Step by Step video series below :-
    For more such videos subscribe / questpondvideos
    JavaScript Interview Questions: • JavaScript Interview Q...
    Learn Angular tutorial step by step tinyurl.com/yc...
    ASP.NET MVC Core Interview Questions with answers:- • ASP.NET MVC Interview ...
    C# interview questions and answers:- • C# Interview Questions...
    C# tutorial for beginners(4 hrs):- • C# Tutorial for Beginn...
    Learn Azure Step by Step:- • Azure Tutorial for Beg...
    Azure AZ-900 fundamentals certification :- • AZ 900 Certification |...
    AZ- 204 certification Azure:- • Azure 204 Certificatio...
    Learn MVC 5 step by step in 16 hours:- • Learn ASP.NET MVC 5 ( ...
    Learn Design Pattern Step by Step goo.gl/eJdn0m
    Learn MSBI Step by Step in 32 hours:- goo.gl/TTpFZN
    Learn SQL Server Step by Step tinyurl.com/ja4...
    Python Tutorial for Beginners:- • Python Tutorial for Be...
    Learn Data Science in 1 hour :- tinyurl.com/y5...
    Learn Power BI Step by Step:- tinyurl.com/y6...
    PHP Interview Questions : • PHP Interview Question...
    -----------------------------------------------------------------------
    For more details :-
    🌐 Website : www.questpond.com
    📱 Mob. No. : +91-9967590707 / +91 7700975156 / +91-22-49786776
    📧Email : questpond@questpond.com / questpond@gmail.com / questpond@yahoo.com
    Share, Support, Subscribe and Connect us on!!!
    UA-cam: / questpondvideos
    Twitter: / questpond
    Instagram : / questpond
    Facebook : / questpond
    #VarKeyword #DynamicKeyword #C#InterviewQuestions&Answers C#Keywords #CSharpInterviewQuestions #InterviewQuestionsforC#

КОМЕНТАРІ • 46

  • @questpondvideos
    @questpondvideos  3 роки тому +4

    30 Important C# Interview Questions : ua-cam.com/video/BKynEBPqiIM/v-deo.html
    Software Architecture Interview Questions : ua-cam.com/video/AtTgcbLOqMM/v-deo.html
    25+ OOPS Interview Questions : ua-cam.com/video/u99wAoBjDvQ/v-deo.html
    20+ SQL Server Interview Questions : ua-cam.com/video/SEdAF8mSKS4/v-deo.html
    10+ Power BI Interview Questions : ua-cam.com/video/Cozc9WNBRt4/v-deo.html
    20 MSBI Interview Questions : ua-cam.com/video/Nw_sHEKnOUE/v-deo.html
    SQL Server Joins : ua-cam.com/video/KTvYHEntvn8/v-deo.html
    SQL Step by Step - ua-cam.com/video/uGlfP9o7kmY/v-deo.html
    Angular Step by Step Tutorial for Beginners : ua-cam.com/video/-9VcW7MBDs8/v-deo.html
    25 Angular Interview Questions : ua-cam.com/video/-jeoyDJDsSM/v-deo.html
    25 Important ASP.NET Interview Questions : ua-cam.com/video/pXmMdmJUC0g/v-deo.html
    35 Important JavaScript Interview Questions : ua-cam.com/video/Zb4dPi7CANU/v-deo.html
    20 MySQL Interview Questions : ua-cam.com/video/9hfjC-BpY20/v-deo.html
    5 MSBI Interview Questions : ua-cam.com/video/5E815aXAwYQ/v-deo.html

  • @RikinPatel13
    @RikinPatel13 2 роки тому +9

    One more diff. >> You can change type of dynamic variable where as var you can not change type of variable.
    E.g var x= 10;
    x="test"; ❌️
    dynamic y=10;
    y="test"; ✅️

  • @seanishok04
    @seanishok04 3 роки тому +7

    This seems to be simple one line explanation. Please explain some pros and cons and also in what scenarios we use Var and Dynamic keywords.

  • @bharathyadav3614
    @bharathyadav3614 3 роки тому +8

    Also var should be initialised at the time of declaration, dynamic may not be.
    Example:
    var name = “Bharath”; ✅
    var name; ❌
    dynamic value = 100; ✅
    dynamic value; ✅

    • @ankmeyester
      @ankmeyester 3 роки тому +2

      You're very knowledgeable sir. Thank you 🙏

    • @questpondvideos
      @questpondvideos  3 роки тому +1

      Thats natural if you do not have value assigned compiler will not know the data type.

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

      Good

  • @reazuddinahmed1080
    @reazuddinahmed1080 3 роки тому +1

    You are more than outstanding teacher...
    The best teacher of the planet...

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

      Same here

  • @devaranji6647
    @devaranji6647 3 роки тому +1

    Var determines things during compile time .its statically typed. While dynamic determines types during runtime .its dynamically typed

  • @delhitepawan5804
    @delhitepawan5804 3 роки тому +1

    Shiv ji, Request you to give some real world application so we can understand it better 🙏

  • @balasenk
    @balasenk 3 роки тому +1

    As you said, I have never used dynamic in the project but if I had an interview will definitely end up in negative, thanks for your great explanation.

  • @imranamin369
    @imranamin369 Рік тому +1

    If var is static and detrmine the type at compile time then why don't we declare a variable with the same type as on right side. Say var i = 123 to int i = 123. In this way var has no need to be used instead of the desired type

    • @hemantha6468
      @hemantha6468 10 місяців тому

      Same doubt for me tooo. If you got any clarification on this please let me know ..

    • @shaiksha229
      @shaiksha229 10 місяців тому

      int i=10;
      i = 20;
      Possible...but
      var i =10;
      i = 20; // it doesn't work

    • @imranamin369
      @imranamin369 10 місяців тому

      @@shaiksha229 Then why don't we use const instead of var. I mean what is the benifit of var rather that const if they are same in behavior

    • @shaiksha229
      @shaiksha229 9 місяців тому

      ​@@imranamin369 const is limited to certain types like primitive and strings. In simple, use const when you have value of primitive/string, use var if you want your complier to infer the type and you can use var for any type not just limited to primitive and strings.
      Hope you are clear with this

  • @thefattysplace
    @thefattysplace 3 роки тому +3

    I still think the best option is to not use var or dynamic, but just declare it using the correct type to start off with.

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

    Super Duper....As usual rocking lesson.

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

    Best answer for interview 👍

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

    Simple nd interesting logic behind var & dynamic..👍

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

    Great tutorials. Microsoft should hire you to rewrite them their complete documentation.
    Thank you

  • @jayandrapatil
    @jayandrapatil 10 місяців тому

    There are many thing's people ask in interviews but hardly use them in projects. I'm sure there are 90% people doing cut, copy, paste in the projects.

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

    Q1. When we should use Dynamic keyword in our code?

  • @aniljha6106
    @aniljha6106 3 роки тому +1

    You have missed to cover when to use what

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

    Well explained

  • @sidharthmahapatra3359
    @sidharthmahapatra3359 Рік тому

    When to use var keyword and when to use dynamic keyword?

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

    It Useful for me

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

      Yes same here

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

    Nice

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

    HI! thank you for your videos. Last version of visual studio suggest (rigth button-> quick actions) replacing var for the real type. So, looks like they want to deprecate var keyword? Thank you again, very good work!

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

    Hi sir, in angular, how inherit class and how to send new input data from UI to database. kindly clarify me

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

    then what is the benfit of Dynamic

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

    How does she compiler figure out the type for i if it doesn't know what y.Length is?

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

    record vs dynamic C#

  • @cubanlincoln1767
    @cubanlincoln1767 Рік тому

    MIrosoft is crazy:
    First: Javascript does not have strong type variables, this is a big mistake, let's solve this creating Typescript, a strong type Javascript
    Later: C# does not have dynamic types in variables(the reason the created Typescript), lets introduce this into C#
    WTF

  • @srinivasrao7794
    @srinivasrao7794 2 роки тому +1

    Always your videos there is no real info, kids also knows what is var and dynamic. You need to provide info for why to use dynamic.

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

      Quiet to sad to see you think this is for kids.Must be you are genius. But many still do not know the basic difference.
      Happy learning

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

      Agreed with srinivas, not only no real info most of the video, when the real info drops its wrong and uploader is a lazy eff who can't re-record a short 6minute video.

  • @mikeraz594
    @mikeraz594 3 роки тому +2

    var and dynamic are the 2 worst concepts ever added to any langauge

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

      And interviewers make out life worst asking these questions during interview sad state of affair :-)