Any Answers??
Archive for the ‘Questions’ Category
Q 9: Why foreach requires IEnumerable, not IEnumerator?
Posted by Ankush on May 18, 2012
Posted in Questions | Tagged: .net, questions | Leave a Comment »
Question on Class Type (Sealed, Public , Virtual)
Posted by Ankush on November 11, 2011
While desgingn the application we normally create classes. Here is a very interesting question:
What’s your opinion on whether to choose “sealed” classes as default, or to leave everything open (public or virtual)?
Share your ideas/thoughts…
Posted in Questions | Tagged: Class, Design, Sealed, Virtual | Leave a Comment »
Question # 9 : You want to cache objects (say, from a database) but still allow them to be garbage collected when necessary
Posted by Ankush on April 25, 2011
Here comes another question after a long wait
any possiable solution?
Posted in Questions | Tagged: Cache, Thread | Leave a Comment »
Question 8 # How to get the Return Values from Each Delegate in a Multicast Delegate
Posted by Ankush on March 3, 2011
Lets say you have created a multicast delegate. You need to be able to access the return value of each delegate that is invoked in the multicast delegate.
How will you do that?
Posted in Questions | Tagged: Delegate, Delegates, return | Leave a Comment »
Question 7: How to find whether a DLL or EXE is managed or unmanaged
Posted by Ankush on February 24, 2011
What is best way to check if an assembly is managed or not?
Cheers!
Posted in Questions | Tagged: Assembly, Managed | 2 Comments »
Question 6: Controlling Delegates and Multicast Delegate
Posted by Ankush on February 23, 2011
You have created a multicast delegate. When you invoke it, each delegate gets fired. You need want more control on this. Basically you want a fine control over:
a. order in which each delegate is invoked
b. firing only a subset of delegates
c. firing each delegate based on the success or failure of previous delegates
How will you achieve this?
Hint:
A delegate, when called, will invoke all delegatess to read within its invocation list. These delegates are usually invoked sequentially from the first to the last one added.With the use of the GetInvocationList method of the MulticastDelegate class, you can obtain each delegate in the invocation list of a multicast delegate. This method accepts no parameters and returns an array of Delegate objects that corresponds to the invocation list of the delegate on which this method was called.
Now can anybody offer the code solution:::)
Posted in Questions | Tagged: Delegate, Delegates, Multicast Delegate | 2 Comments »
Question – 5 : Make sure Exceptions Are Not Lost in Finally Blocks
Posted by Ankush on February 21, 2011
Let’s say you have an exception and you have added a finally block. Excetion will be lost and you will not not know what caused the excetion, it will be lost. And You want to protect against losing exception information when using multiple trycatch-finally blocks.
Hint : This really helps when you have multiple try/catch handler and you want to correctly rethrow the exception so that it bubblesup to the outer exception handler.
Do you have any suggestions which you can leave here as a part of the comment?
Posted in Questions | Tagged: Exception handling, Finally, Rethrow, Throw | 8 Comments »
Question # 4
Posted by Ankush on February 9, 2011
Using reflection, you invoke a method that generates an exception. You want to obtain the real exception object to work with it.
Any possible solution ( small code snippet will help
)?
Posted in Questions | 3 Comments »
Question # 3
Posted by Ankush on January 28, 2011
Very simple question, what happens internally when boxing and unboxing happens?
comm..on guys lets hear what you have to say on this one!!!!!
Ans:
Boxing always creates a new object and copies the unboxed value’s bits to the object. On the other hand, unboxing simply returns a pointer to the data within a boxed object: no memory copy occurs.
Source:http://msdn.microsoft.com/en-us/magazine/cc301569.aspx
Posted in Questions | Leave a Comment »
Question Of the Day # 2
Posted by Ankush on January 27, 2011
Thanks for reading and participating in this series. I received several emails this to be made a 2 day event so from now onwards I am going to post the question in every 2 days. In case, if you also have any interesting question and would like to get it answered here, you can email that to me @ ankush.bhatia@live.com and I will post it here!!
So, here comes the another one.
Consider a scenario, you are designing a scientific application (ex: scientific calculator) and you need to handle the very large numbers. How would you design your application to handle this situation. As there is no datatype in .net which can handle very- very large numbers and its calculation so what approch would you take to resolve this. My application is targeting .net framework 2.0.
Keep thinking!!
Answer:
So as you may be aware that .net framework 4.0 already provides a datatype BigInteger to hold the very large numbers.
http://msdn.microsoft.com/en-us/library/system.numerics.biginteger.aspx
If you have to implement this at your own, you can use positional notation system.
Have a look at there for the complete implmentation :http://www.codeproject.com/KB/cs/biginteger.aspx
Posted in Questions | 2 Comments »