I was reading about Value types and Reference Types for the exam 70-536 which I will be giving soon and there were certain things that I already knew already but some of them were new to me and hence I thought I would have a summary post of what I understand of value types and reference types in .net.
Value Type:
The .net CLR(Common Language Runtime) store the data of the value types in a part of the memory called as the stack. The most basic type of variables like Integers, Booleans, Bytes etc are stored as value types by the .net runtime. Value types can be easily created, updated and removed from the stack by the .net runtime.
There are three types of value types:
• The built-in types of the .net framework
• The user defined types
• Enumerations.
Reference Types:
The .net CLR stores reference types in 2 steps; firstly the address of the memory location, called as a pointer is stored in the stack. This pointer points to the address where the actual data is stored in the part of the memory called as the heap. Reference types which are no longer referenced are garbage collected periodically by the runtime. Reference types are generally very effective in passing parameters to functions.
Some of the examples of reference types include strings, objects (of classes; built-in or otherwise) etc. To illustrate more, I did an experiment which demonstrates value type and reference type and how can it be detected if a variable is a value type or a reference type.
SByte a = 0;
Byte b = 0;
Int16 c = 0;
Int32 d = 0;
Int64 e = 0;
string s = “”;
Exception ex = new Exception();
object[] types = { a, b, c, d, e, s, ex };
foreach (object o in types)
{
string value = “”;
if (o.GetType().IsValueType)
{
value = “Value type”;
}
else
{
value = “Reference type”;
}
Console.WriteLine(”{0},{1}”, o.GetType(), value);
}
In my next post, I will write about how to create your own value type and an example of a reference type used for function calls.
I know this is kind of late since i watched the movie fashion about a week back but i have been busy; but nevertheless heres a review of the movie. The first thing that comes to my mind when i think of the movie is the fact that the movie has failed to surprise me like other movies of madhur bhandarkar; infact the movie has disappointed me. I think the movie is not typical madhur bhandarkar and instead of showing the reality( which madhur bhandarkar) is fameous for; this time he has been politically correct for the movie.
Learning Python
I have heard about Python over and over and over again and for reasons not known I have ignored Python over and over again!! But not anymore, I have finally decided to learn python and that too in the right way!
So, the other day while coming back from the college library I picked up two of the books on python(Learning Python and Beginning Python) and have started reading about python. I did read a couple of pages and this is what I have to summarize:
All the above points make python a language I definitely want to learn and I am cursing myself for not learning it for so long. So, do check back soon as I will post about my progress of learning python. Do suggest any resources/ articles/ books on python that you might know in the comments section.