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#
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
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"; ✅️
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.
Ok
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; ✅
You're very knowledgeable sir. Thank you 🙏
Thats natural if you do not have value assigned compiler will not know the data type.
Good
You are more than outstanding teacher...
The best teacher of the planet...
Same here
Var determines things during compile time .its statically typed. While dynamic determines types during runtime .its dynamically typed
Shiv ji, Request you to give some real world application so we can understand it better 🙏
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.
Lol 😂
☺️
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
Same doubt for me tooo. If you got any clarification on this please let me know ..
int i=10;
i = 20;
Possible...but
var i =10;
i = 20; // it doesn't work
@@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
@@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
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.
Super Duper....As usual rocking lesson.
Best answer for interview 👍
Simple nd interesting logic behind var & dynamic..👍
Great tutorials. Microsoft should hire you to rewrite them their complete documentation.
Thank you
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.
Q1. When we should use Dynamic keyword in our code?
You have missed to cover when to use what
Well explained
When to use var keyword and when to use dynamic keyword?
It Useful for me
Yes same here
Nice
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!
Hi sir, in angular, how inherit class and how to send new input data from UI to database. kindly clarify me
Yes
then what is the benfit of Dynamic
How does she compiler figure out the type for i if it doesn't know what y.Length is?
She :-) uses reflection internally.
record vs dynamic C#
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
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.
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
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.
var and dynamic are the 2 worst concepts ever added to any langauge
And interviewers make out life worst asking these questions during interview sad state of affair :-)