Knowing When to Use Override and New Keywords C#

So it all started with this. There was some code which periodically archived log files.Archival was failing arbitrarily (That’s a different issue). In the process of fixing that issue , repeated debugging and stuff I came across this Using quite frequently

using (FileStream streamReader = File.OpenRead(filename))
{
// do something
}

It was really after a long time that I was interested in checking out what was the whole thing about this Using block.Until then, I was interested in only fixing the issue and this block just looked like a normal block of statements to me, at least I dint care much more about it.

Then comes this whole story about its connection with IDisposable Interface

http://www.dotnetperls.com/using which said it was a synctactic sugar. So I went about seeing what a syntactic Sugar was (I had heard it somewhere before)

http://en.wikipedia.org/wiki/Syntactic_sugar which introduced the related term Syntactic Salt to me, which spoke about the compiler warning issued unless the new keyword is used to specify that the hiding is intentional (C#). Cursing my lack of context , I went about seeing what it was

http://msdn.microsoft.com/en-us/library/435f1dw2.aspx.

Partly understanding what it was and having more confusions about how override was different,I went through this

http://msdn.microsoft.com/en-us/library/ms173153.aspx and after I was done with it, It was an AHAA moment, to look at where I started and where I ended up. And now I am curious to check how these behaviors are expected to behave in JAVA. Will Keep Editing this post as I dive deeper .

Advertisements