1.What are Value Types ? Give example
Variables that store data are called value types. Value types are stored on stack.
They contain the actual values. eg-int, enum, structs.
Variables that store data are called value types. Value types are stored on stack.
They contain the actual values. eg-int, enum, structs.
2.What are Reference Types? Give Example.
Variables that store reference to actual data are called Reference types.Reference types
stored on heap but contain the address on heap.
eg-class,interface,delegate,string,object, Array
3.Difference between value type and reference types ?Variables that store reference to actual data are called Reference types.Reference types
stored on heap but contain the address on heap.
eg-class,interface,delegate,string,object, Array
Value Type | Reference Type |
They are stored on stack | They are stored on heap |
Contains actual value | Contains reference to a value |
Cannot contain null values. However this can be achieved by nullable types | Can contain null values. |
Value type is popped on its own from stack when they go out of scope. | Required garbage collector to free memory. |
Memory is allocated at compile time |
4.Diff bt stack and heap
Stack | Heap |
Values are stored on one another like a stack. | Values are stored in random order.like dumped into a huge space |
Used for value type | Used for reference types |
5. Whats the output of the following program ?
1. int x = new int();
x = 20;
int y = new int();
y = x;
y = 30; //Line3
return x;
At Line 3 only y value is changes. "x" has its own location on stack which is not
affected by this and hence retains is old values.
2. class Numbers
{
public int MyValue;
}
Numbers x = new Numbers();
x.MyValue = 3;
Numbers y = new Numbers();
y = x;
y.MyValue = 4;
Console.WriteLine( x.MyValue);
Output- 4. Both x and y are pointing to the same location on the heap.
6.What is boxing and unboxing ?
Boxing-- Converting a value type to a reference type .This is implicit.
During boxing follo 3 things happen-
Memory is allocated on heap,
Value is copied from stack to heap,
Reference is updated to point t heap
eg-
int i = 123;
object o = i;
here if you make i= 456;
then o=123, //value does not change
Unboxing- Converting reference type to value type.
The value which is being unboxed has to be boxed first.
eg- int j = (int) o;
7.Are Value Type sealed ?
Yes
8.Can you implement IDisposable for value type ?
Structs being a value type can inherit IDisposable interface
10.how do you get size of value type ?
using SizeOf operator.
11.When you declare int i,j hos is it alocated?
Both of them are allocated on the stack at the same time and they go out of scope at the
same time.
12.What do you mean by Pass By Value ?
Actual value is copied to another variable eg-
calling method-- Actual Method
int a=4, Add(int a,int b){
int b=5, a=6,b=7 }
Add(4,5)
Print a and b --Line 1
Even though the value of a and b is changed in the actualfunction it does not chane in
line 1.
13.What do you mean by Pass By Reference?
The calling functions passes the address of the variable instead of the actual values.Any
changes made inside the actual method will be reflected in the calling function.
eg-
calling method-- Actual Method
int a=4, Add(ref int a,ref int b){
int b=5, a=6,b=7 }
Add(ref 4,ref 5)
Print a and b --Line 1
The value at Line 1 willl be a=6,b=7
13.What do you mean by Pass By out?
This is similar to pass by ref. Only diff is before passing the values they need not be
initialized.But they have to be initialized inside actual method.They are mailny used in remoting.
eg-
calling method-- Actual Method
int a, Add(out int a,out int b){
int b, a=6,b=7 }
Add(out 4,out5)
Print a and b --Line 1
The value at Line 1 willl be a=6,b=7
14.what are params ?
They are used when you do not know how many variables you will be passing across methods.
eg-
calling method-- Actual Method
method(1,2,3,4) method(int a,params int[])
The param array should be last while declaring method arguments.
15.What the difficult parameter type used when calling methods in c# ?
Pass by Value
Pass by Value
13.What are diff types of parameter in c# ?
Value parameter(in), Reference/ inout paramete ref),Output parameter(out),
Parameter Array(param)
Thanks for the article, Great work!
ReplyDeleteThe statement:
"Reference types stored on "heap" but contain the address on "heap".
may not be accurate: the address is stored on the stack, which points to a memory location on the heap.
Great job!
ReplyDelete30. ......…….are a kind of parameterized data structure that can work with value types as well as reference types.
DeleteSome more selected ... http://net-informations.com/faq/default.htm c# interview question and answers.
ReplyDeleteMakki
AllitTechnolgies Interview Question and Answers :
ReplyDeleteDotnet Interview Question and Answers
30. ......…….are a kind of parameterized data structure that can work with value types as well as reference types.
ReplyDeleteThanks
ReplyDeleteWHAT is line-1 means in q.12
ReplyDeleteIt is really a great work and the way in which u r sharing the knowledge is excellent.Thanks for helping me to understand basic concepts. As a beginner in Dot Net programming your post help me a lot.Thanks for your informative article.
ReplyDeleteDot Net Training in chennai |dot net training institute in velachery
ReplyDeleteGiven so much information in it. its very useful .perfect explanation about Dot net framework.Thanks for your valuable information. dot net training and placement in chennai | top10 dot net training institutes in chennai
Learn how to create application using C# programming language in hindi/urdu with complete notes of all lectures regarding C#. C# programming tutorial with OOP(Object-oriented Programming) concepts in easy hindi/urdu (basic to advance level).
ReplyDeletePlease Visit: http://www.csharp-roman-urdu.blogspot.com
It is really a great work and the way in which u r sharing the knowledge is excellent.
ReplyDeleteThanks for helping me to my career. As a beginner in Dot Net programming your post help me a lot.Thanks for your informative article. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things
dot net training in velachery | dot net training in chennai
The dotnet interview questions shared are very much useful My sincere thanks for sharing this post and please continue to share this post
ReplyDeleteDot Net Training in Chennai
This comment has been removed by the author.
ReplyDeleteGreat post. This article is really very interesting and enjoyable. I think its must be helpful and informative for us. Thanks for sharing your nice post.
ReplyDeletedotnet training in chennai
Thanks for sharing use interview questions on .Net technology. While preparing for my job interview, your article helped me a lot to sharpen my skills and do well in my interview.
ReplyDeleteBig data Analytics Training in Chennai | Software Testing Training in Chennai
More...C# Interview Questions
ReplyDeleteLing
This comment has been removed by the author.
ReplyDelete"I very much enjoyed this article.Nice article thanks for given this information. i hope it useful to many pepole.php jobs in hyderabad.
ReplyDelete"
Excellent Artical.Thank you very much for your hard work.
ReplyDeleteUNIX Shell scripting training in chennai | ORACLE apps finance training in chennai | Informatica Online Training
This comment has been removed by the author.
ReplyDeleteVery nice article Thanks for sharing
ReplyDelete.Net Online Training Bangalore
Well Said, you have furnished the right information that will be useful to anyone at all time. Thanks for sharing your Ideas.
ReplyDeleteSelenium training in Chennai
Selenium training in Bangalore
Selenium training in Pune
Selenium Online training
Attend The Python training in bangalore From ExcelR. Practical Python training in bangalore Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Python training in bangalore.
ReplyDeletepython training in bangalore
After reading your article I was amazed. I know that you explain it very well. And I hope that other Python classes in pune readers will also experience how I feel after reading your article.
ReplyDeleteThanks for sharing the updating information
ReplyDeleteSanjary Academy is the best Piping Design institute in Hyderabad, Telangana. It is the best Piping design Course in India and we have offer professional Engineering Courses like Piping design Course, QA/QC Course, document controller course, Pressure Vessel Design Course, Welding Inspector Course, Quality Management Course and Safety Officer Course.
Piping Design Course in Hyderabad
This is very good content you share on this blog. it's very informative and provide me future related information!!
ReplyDeleteArtificial Intelligence Course
You can make C# Nullable Types such as int and double to allow null to be their values. Null values are only storable to reference types like string and other objects.
ReplyDeleteIt is very informative. Thanks for sharing.
ReplyDeleteDigital Marketing Agency in Mumbai
ReplyDeleteHey Nice Blog!! Thanks For Sharing!!!Wonderful blog & good post.Its really helpful for me, waiting for a more new post. Keep Blogging! devops training in chennai | devops training in anna nagar | devops training in omr | devops training in porur | devops training in tambaram | devops training in velachery
Cool stuff you have and you keep overhaul every one of us
ReplyDeletelearn360digitmg artificial intelligence online course
I feel a lot more people need to read this, very good info! .
ReplyDelete360digitmg data science courses online
Dot Net programming your post help me a lot.Thanks for your informative article. And i hope this will be useful for many people.
ReplyDeletepython training in chennai
python online training in chennai
python training in bangalore
python training in hyderabad
python online training
python flask training
python flask online training
python training in coimbatore
ReplyDeleteThanks For Sharing The Wonderfull Content With Us !
Best Degree College In Hyderabad
Best Degree College In Attapur
Top And Best BBA College In Hyderabad
Top And Best B.Com College In Hyderabad
Thanks you sharing this Interview Questions List
ReplyDeleteIt was wonerful reading your conent. Thankyou very much. # BOOST Your GOOGLE RANKING.It’s Your Time To Be On #1st Page
ReplyDeleteOur Motive is not just to create links but to get them indexed as will
Increase Domain Authority (DA).We’re on a mission to increase DA PA of your domain
High Quality Backlink Building Service
1000 Backlink at cheapest
50 High Quality Backlinks for just 50 INR
2000 Backlink at cheapest
5000 Backlink at cheapest
It was wonderfull reading your article. Great writing styleiamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder
ReplyDeleteIt was wonderfull reading your article. Great writing styleiamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder iamlinkfeeder
ReplyDeleteThe medical coverage commercial center is surely testing, however check your fortunate starsIamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder
ReplyDeleteDavid Forbes is president of Alliance Marketing Associates IncIamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder IamLinkfeeder
ReplyDeleteAnnabelle loves to write and has been doing so for many years.Backlink Indexer My GPL Store Teckum-All about Knowledge
ReplyDeleteVery informative post, thanks for share it.
ReplyDeleteHindi Urdu Interviews
4K Youtube Video Download Process
ReplyDeleteghd sports
RTGS kaise kare
It is extremely nice to see the greatest details presented in an easy and understanding manner.
ReplyDeletedata scientist certification malaysia
Supradyn Tablet is use in very easy in people. this tablet is multivitamin
ReplyDeletethis is really nice to read..informative post is very good to read..thanks a lot!
ReplyDeletedata scientist training in malaysia
ReplyDeleteWonderful blog.Thanks for sharing such a worthy information..
Applications of Data Science
Data Science Applications
It was wonderfull reading your article. Great writing style # BOOST Your GOOGLE RANKING.It’s Your Time To Be On #1st Page Our Motive is not just to create links but to get them indexed as will Increase Domain Authority (DA).We’re on a mission to increase DA PA of your domain High Quality Backlink Building Service 1000 Backlink at cheapest 50 High Quality Backlinks for just 50 INR 2000 Backlink at cheapest Captured Current News
ReplyDeleteHappy to read the informative blog. Thanks for sharing
ReplyDeletebest java training institute in chennai
best java training institute in chennai
Nice blog. Informative and knowledgeable content. Big thumbs up for this blog. I really enjoyed this blog. Thank you for sharing with us.
ReplyDeleteData Science Course Training Institute in Hyderabad with Placements
Thank you ever so for you article. Really Cool.
ReplyDelete. net online training
dot net online training hydarabad
Nice information excellent work
ReplyDeleteMPM Corner
vegamovies
ibomma
teluguwap net
Good to become visiting your weblog again, it has been months for me. Nicely this article that i've been waited for so long.
ReplyDeleteI will need this post to total my assignment in the college, and it has exact same topic together with your write-up. Thanks, good share.
I am impressed by the information that you have on this blog. It shows how well you understand this subject.
data scientist training in hyderabad
Veri Informative Blog... keep it up. Thanks For Sharing.
ReplyDeletePersonal loan for CIBIL defaulter
Nice Post
ReplyDeleteJim Corbett Hotels
Thanks for sharing this blog.
ReplyDeleteWheel Balancing Machine
True eye seat ability pretty environment major. Billion rich after. Decade eye force significant hotel institution plant.education
ReplyDeleteFuture city Congress certain.
ReplyDelete