background preloader

What Great .NET Developers Ought To Know (More .NET Interview Questions)

What Great .NET Developers Ought To Know (More .NET Interview Questions)

Interview Questions (Scott Hanselman) & Answers (Muhammad Adnan Amanaullah) :) - live wid knowledge :) Let’s answer Scott Hanselman interview questions. First of all, I would like to clear, purpose of this post is only educational/sharing knowledge. May be i am wrong and i would love if any1 of you correct me through commenting to this post with authentic references. i will really appreciate the contributors. Many days back I saw Scott hanselman website and kept reading his many other blogs and I found a list of interview questions which he said, he asked usually and he thinks should be known by .net guys at different levels. I got many (some wrote and answered as well) interview questions and put them at single platform just for knowledge sharing @ . Actually I always like to be part of interviews questions so I decided to write answer of them according to my little knowledge. I can say now, it’s really great learning/evaluation experience when I was thinking/writing their answers as to just skim them is another thing than to answer them.

Multi-threading in .NET In .NET 2.0+, if you want to have something run on another thread, you have a number of choices: The classical System.Threading.Thread classThe not-so-known System.Threading.ThreadPoolThe System.ComponentModel.BackgroundWorkerDelegates invoked asynchronously Let's see how we would do it in each case, and what would be the benefits. private void ThreadMethod(Object state) Using System.Threading.Thread You start a new System.Threading.Thread instance and pass it a pointer to the thread method wrapped in a System.Threading.ParameterizedThreadStart (for an optional state parameter) or System.Threading.ThreadStart delegate, then, you start it, by calling Start: Thread thread = new Thread(state => ThreadMethod(state)); thread.Start(state); As you can see, I am using the new .NET 3.5 lambda syntax for delegates. If you want to wait for the thread to exit, do this: thread.Join(timeout); Using System.Threading.ThreadPool Boolean result = ThreadPool.QueueUserWorkItem(ThreadMethod, state); handle.WaitOne();

Thread Synchronization in .NET This comes after my last post Multi-threading in .NET. There are several synchronization mechanisms you can use in your .NET applications, so choosing among them must be done wisely. First you must decide one thing: Do you need to synchronize threads in different processes on the same machine? If so, the available possibilities are: If you only want to synchronize threads inside a single process, you have more options, but first you must decide on this: Do you want all of your threads to be equally treated? If so, try these: All of the above classes, but you can skip setting the name of the synchronization object;System.Threading.Monitor (best known as the lock keyword): only one object at a time can have hold of the synchronization lock;System.Runtime.CompilerServices.MethodImplAttribute attribute: if used with System.Runtime.CompilerServices.MethodImplOptions.Synchronized option, marks a method as synchronized, so there can be only one thread at a time running it. Happy multi-threading!

To Do - clojure-clr - GitHub In no particular order, here are some of the pending development tasks. Implement printf The format function in core.clj depends on Java’s String.format, a printf-style formatter. There is no BCL equivalent, so we will have to implement it. This has been partially written. Still awaiting completion: extend float spec to BigDecimal arguments extend float spec to System.Decimal implement HexFloat spec implement grouping for General Float spec implement grouping for integer spec / BigInteger arguments Loading of standard environment There are several .clj files that are part of the standard environment of ClojureJVM that we have not translated yet. clojure/xml.clj The implementation relies extensively on SAX parsers as defined in org.xml.sax and javax.xml.parsers. Proxy and genclass Implement bean (in core_proxy.clj). Testing There are more than 500 unit tests for the basic runtime libraries in the Clojure.Tests project. There should be a set of tests developed for compiler functionality. seque

Full Screen Mode in C#. Free source code and programming help Download source files - 8.66 Kb Introduction There are situations where you want your application to go into a full screen presentation mode. How to do it? I am presenting a simple solution using C#. When the F11 key is pressed, I create another form that has its WindowState property set to Maximized, the background color is set to Black. The trick here is to set the main application's form's owner to that of the second form. Conclusion Here is just a simple method for an application to enter to a full screen mode without writing a lot of resizing code in the main application. If you haven't heard There seem to be more readers of my posts than there used to be, so I wanted to mention a project I've been slowly working on. I've been porting MIT Scheme to the .NET CLR. MIT Scheme has two major components: the ‘microcode’ which provides the memory model and the primitives, and the ‘runtime’ which is the Scheme code and libraries that come with the system. Once upon a time, the ‘microcode’ really was microcode. I'm doing this for fun and to try out different ideas I've had about interpreter implementation. So why am I bringing this up? As I have mentioned in earlier posts, the two things that an interpreter does most is variable lookup and continuation management. When an interpreter compatible environment is used, there is little choice but to represent the environment as a linked list of frames. In my attempted port of Object Lisp, I would get this all the time. Ok, back to my version of MIT-Scheme.

Designing a .NET Computer Developing Renraku has led me to some interesting thoughts, not the least of which is the feasibility of a .NET computer. Existing computers know only a few core things: Move to/from memory and registersBranchPerform arithmetic All the other smarts are built on top of that, leaving us with layer upon layer of complexity. The CPU will execute raw CIL blobs and exposes hardware interfaces and interrupts. Since the CPU is going to be executing CIL directly, it's going to have to deal with object initialization, virtual method lookups, array allocation, memory manager, and many other tasks that existing systems handle purely in software. Hypervisor The hypervisor, like everything else, will be built completely in managed code. The hypervisor provides a standardized interface to talk to drivers and memory, which are verified. Bootloader The bootloader is a standard .NET binary, and its job is simply to hand control off to the OS. Unlike most OSes, it won't get free reign over the system.

Welcome to Remotesoft Salamander .NET Decompiler (C#, C++, VB.NE Salamander is a .NET decompiler that converts executable files (.EXE or .DLL) from Intermediate Language (IL, MSIL, CIL) binary format to high-level source codes, such as C#, managed C++, Visual Basic.NET, etc. For more than 8,000 classes that have been tested, Salamander always produces equivalent and recompilable codes that are remarkably close to the original source codes. What other people say ... 1. ASP.NET PRO article 2. Our decompiler now automatically removes string encryptions injected by obfuscators, for more info click here To use salamander online, please upload a .NET executable file and then click the "Decompile" button. Pricing and Availability Our decompiler is available at $1099 per license. All transactions are processed on secure websites (SSL). Components Code Examples Features For sales, questions with regard to salamander, please send emails to huisinro@stanfordalumni.org or sales@remotesoft.com

CAP_FontInstaller - A basic (un)installer class for application Introduction Every once in a while, the applications we develop require fonts that may or may not be in the user's system. A common solution is to bundle the font files with the rest of the application setup and to install them with everything else. Packages like MSI, NSIS, or Inno make this easy enough. A drawback is that your fonts become permanently visible system-wide and, for example, the user could at any point remove/uninstall the fonts your application relies on. To prevent this scenario, you could implement code that checks the fonts' status every time your application is run and, if need be, proceeds to self-terminate, to warn the user, or to install the fonts on the fly. Of course, if you are installing fonts on the fly, you could take it a step further and limit the lifespan of the font to the application's execution. Using the code A straightforward use of the code would follow these steps: Including the AP_FontInstaller.h and AP_FontInstaller.cpp in your project. Notes

The Stack Is An Implementation Detail, Part Two A number of people have asked me, in the wake of my earlier posting about value types being on the stack, why it is that value types go on the stack but reference types do not. The short answer is “because they can”. And since the stack is cheap, we do put them on the stack when possible. The long answer is… long. I’ll need to give a high-level description of the memory management strategies that we call “stack” and “heap”. The CLRs garbage-collected heap is a marvel of engineering with a huge amount of detail; this sketch is not actually how it works, but it’s a good enough approximation to get the idea. The idea is that there is a large block of memory reserved for instances of reference types. If we’re in that situation when new memory is allocated then the “high water mark” is bumped up, eating up some of the previously “free” portion of the block. If we have holes then we can maintain a “free list” – a linked list of holes. Now compare this to the stack. aside { A few asides:

Zombie Operating Systems and ASP.NET MVC In 1973, an operating system called CP/M was born. CP/M had no directories, and filenames were limited to 8.3 format. To support input and output from user programs, the pseudofiles COM1, COM2, COM3, COM4, LPT1, LPT2, CON, AUX, PRN, and NUL were provided. In 1980, Seattle Computer Products decided to make a cheap, approximate clone of CP/M, called 86-DOS. 86-DOS therefore had no directories, supported 8.3 file names, and included the pseudofiles COM1, COM2, COM3, COM4, LPT1, LPT2, CON, AUX, PRN, and NUL. Further, because many programs always saved their files with a specific extension, any file with these names and an extension was treated as identical to the filename without the extension. In 1981, Microsoft Corporation purchased the rights to use 86-DOS, renamed it MS-DOS, and shipped it to customers. In 1983, Microsoft Corporation released MS-DOS 2.0. In 2002, Microsoft announced the imminent release of the .NET framework. But ASP.NET MVC was based on ASP.NET.

L Sharp .NET Why are thread safe collections so hard? Writing a collection which is mutable, thread safe and usable is an extremely difficult process. At least that’s what you’ve likely been told all through your schooling. But then you get out on the web and see a multitude of thread safe lists, maps and queues. If it’s so hard, why are there so many examples? The problem is there are several levels of thread safe collections. For Example, lets build a data thread safe List<T>. And there you have it. But if building a data thread safe list is so easy, why doesn’t Microsoft add these standard collections in the framework? Answer: ThreadSafeList<T> is a virtually unusable class because the design leads you down the path to bad code. The flaws in this design are not apparent until you examine how lists are commonly used. static int GetFirstOrDefault(ThreadSafeList<int> list) { if (list.Count > 0) { return list[0]; } return 0;} This code is a classic race condition. I refer to procedures like Count as decision procedures. Summary of the changes

Related: