10 Essentials C# keywords every .Net developer should know before attending an Interview #AspNetInterviewQuestionsSeries
1. Var and/vs Dynamic
With Var keyword properties / Methods /Operators etc are resolve at compile time.
Var keyword is static typed and type cannot be change,Once you have assigned the type to var.
With Dynamic keyword properties / Methods /Operators etc are resolve at runtime.
type can be change once it is already assigned.
Var keyword is static typed and type cannot be change,Once you have assigned the type to var.
var i = "abc"; i = 1 ; //you cannot assign it integer value once it has been marked as string
With Dynamic keyword properties / Methods /Operators etc are resolve at runtime.
type can be change once it is already assigned.
dynamic i = "abc"; i = 1 ; //you can change the type in dynamic Console.WriteLine(i.anything); //error will be given at runtime
2. Const and ReadOnly
- Constants are evaluated at the compile-time, while the read-only variables are evaluated at the runtime.
- Constants support only value-type variables, while read-only variables can hold reference type variables.
- Constants should be used when the value is not changing during the runtime, and read-only variables are used mostly when their actual value is unknown before the runtime.
static readonly string readonlystring; //you can levae it blank and can assign value at runtime,assign object to it const string constring ="abc"; // you have to assign some value to const while declaring,you can assign ref type to const
Checked keyword is to check integral arithmetic overflow.
What will happen if you are assigning the greater value to your int than its maximum value?
you will get the wrong result,to check above condition and throw airtmetic overflow use Checked keyword either in block () or in expression {} manner.
//checked block int checkedk = int.MaxValue; Console.WriteLine(checked(checkedk+ 20)); //checked expression checked { int i = 10; int i3 = 2147483647 + i; Console.WriteLine(i3); }
unchecked keyword is just opposite of that it will not throw any exception. by default int ,byte are unchecked.
4. AS and IS keyword
Both keywords are used for safe cast typing with lill diff in their working.
IS :
checks whether the type of an given object is compatible with the new object type and returns Boolean type true or false.
AS:
checks whether the type of an given object is compatible with the new object type and returns object if it is compatible or null if it isn't.
person p = new person(); Men men = new Men(); Men m2 = p as Men; Console.WriteLine(p is Men); Console.WriteLine(men is person); if(m2 !=null) { Console.WriteLine("m is person type"); }else { Console.WriteLine("m is not person type"); }
5. Volatile and Lock keyword
volatile indicates that field can be modified by multiple thread. volatile keyword can be applied only to fields of class/struct.
Lock keyword ensures that if one thread is accessed any object in lock block that will not be accessible by another thread, it will have to wait until that thread release the accessed object.
All the points you described so beautiful. Every time i read your i blog and i am so surprised that how you can write so well.
ReplyDeleteDevops training in Chennai
Devops training in Bangalore
Devops Online training
Devops training in Pune
I was looking for this certain information for a long time. Thank you and good luck.
ReplyDeletejava training in annanagar | java training in chennai
java training in marathahalli | java training in btm layout
java training in rajaji nagar | java training in jayanagar
java training in chennai
Awesome! Education is the extreme motivation that open the new doors of data and material. So we always need to study around the things and the new part of educations with that we are not mindful.
ReplyDeleteangularjs-Training in velachery
angularjs-Training in annanagar
angularjs Training in chennai
angularjs Training in chennai
Nice tips. Very innovative... Your post shows all your effort and great experience towards your work Your Information is Great if mastered very well.
ReplyDeletepython training in pune
python training institute in chennai
python training in Bangalore
Excellent and useful blog admin, I would like to read more about this topic.
ReplyDeleteAngularJS Training in Chennai
Angular 6 Training in Chennai
ReactJS Training in Chennai
AWS Training in Chennai
DevOps Training in Chennai
RPA Training in Chennai
R Programming Training in Chennai
Great post thanks for sharing
ReplyDeleteR programming training institute chennai
Nice post. By reading your blog, i get inspired and this provides some useful information. Thank you for posting this exclusive post for our vision.
ReplyDeleteapple iphone service center in chennai | apple ipad service center in chennai | apple iphone service center in chennai
Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.
ReplyDeleteiphone repair in chennai | apple iphone service center in chennai | iphone service in chennai | apple service center chennai | Mobile service center in chennai | iphone repair in chennai | iphone service chennai
Hello I am so delighted I found your blog, I really found you by mistake, while I was looking on Yahoo for something else, anyways I am here now and would just like to say thanks for a tremendous post. Please do keep up the great work.
ReplyDeleteAuthorized iphone service center in Chennai | iphone service center in chennai | Mobile service center in chennai | Authorized iphone service center in Chennai | iphone service center in chennai
Bagi pemula kalian dapat bermain di meja kecil dulu yaa jangan langsung bermain di meja besar. Karena sebagai pemula kalian tentunya belum begitu paham bagaimana sistem permainannya
ReplyDeleteasikqq
dewaqq
sumoqq
interqq
pionpoker
bandar ceme terpercaya
hobiqq
paito warna terlengkap
bocoran sgp
microsoft azure cloud services london
ReplyDeleteWELCOME TO ANIKA TECH SUPPORT
Anika Tech Support managed by a team of professionals utilising a combined 20+ years of experience in IT support and Managed IT services Focusing on Proactive support, continuity, growth and development. We are a forward thinking IT Company who support public and private sector using the latest tech as a driving force for our client’s Success.
nice blog
ReplyDeletedata Science training in chennai
best devops training in chennai
devops training in chennai
best hadoop training in chennai
best hadoop training in omr
hadoop training in sholinganallur
best java training in chennai
nice message
ReplyDeletedata science with python training in Bangalore
Machine Learning training in bangalore
Qlik Sense Training in Bangalore
Qlikview Training in Bangalore
RPA Training in Bangalore
MEAN Stack Training in Bangalore
MERN StackTraining in Bangalore
Blue Prism Training in Bangalore
Good Post. I like your blog. Thanks for Sharing.
ReplyDelete.Net Training in Noida
It was a very good experience,Faculty members are very knowledgeable and cooperative. Specially My trainer teaching more as he focused upon practical rather than theory. All together it was an enlightening and informative course.
ReplyDeleteSAP HANA training institutes in bangalore
SAP HANA training in bangalore
Best SAP HANA training institutes in bangalore
SAP HANA training course content
SAP HANA training interview questions
SAP HANA training & placement in bangalore
SAP HANA training center in bangalore
Thanks for sharing such a great blog Keep posting.
ReplyDeleteb2b data providers
contact database
data provider
business directory
sales intelligence
marketing intelligence
relationship management
sales automation tools
crm software
company database
This post is really nice and informative. The explanation given is really comprehensive and useful.
ReplyDeletesap business intelligence training
Thanks for this informative blog...
ReplyDeletePython Training in Bangalore
Thanks you for sharing this unique useful information content with us...
ReplyDeleteDevops Training in Bangalore
Thanks for this informative blog...
ReplyDeleteJava Course in Bangalore
The blog is very useful and informative thanks for sharing SD WAN TRAINING
ReplyDeleteI am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic.
ReplyDeletesap bw on hana tutorial
ReplyDeleteExcellent blog with lots of information, keep sharing. I am waiting for your more posts like this or related to any other informative topic and interesting blog and really very helpful article.
Data Science Training In Chennai | Certification | Data Science Courses in Chennai | Data Science Training In Bangalore | Certification | Data Science Courses in Bangalore | Data Science Training In Hyderabad | Certification | Data Science Courses in hyderabad | Data Science Training In Coimbatore | Certification | Data Science Courses in Coimbatore | Data Science Training | Certification | Data Science Online Training Course
It was so nice content.I was really satisfied by seeing this content.
ReplyDeletesap hybris training in bangalore
First You got a great blog .I will be interested in more similar topics. i see you got really very useful topics, i will be always checking your blog thank. sap hana training in bangalore
ReplyDeleteBrandstory is the best SEO Company in Dubai, maximizing your online presence with expert strategies and optimal rankings, ensuring high traffic and standing out in the digital competition.
ReplyDelete