Skip to main content

Posts

What are 'closures' in .NET?

In essence, a closure is a block of code that can be executed at a later time, but which maintains the environment in which it was first created - i.e. it can still use the local variables, etc of the method which created it, even after that method has finished executing. The general feature of closures is implemented in C# by anonymous methods and lambda expressions. Here's an example using an anonymous method: using System; class Test {      static void Main()      {           Action action = CreateAction();           action();           action();      }      static Action CreateAction()      {           int counter = 0;           return delegate           {                // Yes, it could be done in one statement;                // but it is clearer like this.                counter++;                Console.WriteLine("counter={0}", counter);     
Recent posts

Basics of Kubernetes

  Kubernetes is an open-source container orchestration framework, it was developed by Google. Kubernetes manages containers it could be a docker container or any other container technology. So we can say that Kubernetes help us manage the containerized application, We can use Kubernetes on a different type of environments let it be a physical server, virtual machines or cloud. What Problem Does It Solve : The rise of microservice architecture has increased the use of container technologies. nowadays a complex enterprise application can have thousands of containers. managing those containers using scripts or self-made tools is very tough and error-prone. Kubernetes like container orchestration tools solve this problem. A container orchestration tool offers the following features High Availability or no downtime Scalability or high performance Disaster recovery Basic Architectures:  Kubernetes cluster is made of at least one master node and connected to it a couple of  worker nodes . The

The 10 Most Common Mistakes That C# Developers Make

C# is an object oriented, strongly-typed language. The strict type checking in C#, both at compile and run times, results in the majority of typical programming errors being reported as early as possible, and their locations pinpointed quite accurately. This can save the C# programmer a lot of time, compared to tracking down the cause of puzzling errors which can occur long after the offending operation takes place in languages which are more liberal with their enforcement of type safety.  However, a lot of programmers unwittingly (or carelessly) throw away the benefits of this detection, which leads to some of the issues discussed in this post. Common Mistake #1: Using a reference like a value or vice versa Programmers of C++, and many other languages, are accustomed to being in control of whether the values they assign to variables are simply values or are references to existing objects. In C#, however, that decision is made by the programmer who wrote the object, not by the

Must-have Tools for Developers

Every developer has list of his favourite tools. These tools make developers more productive and make there life easier. Here are the list of my favourite tools. These are the tools which a developer must have apart from there IDEs. With time and changing focus, this list keeps changing. LinqPad  :  LINQPad is not just for LINQ queries, but any C#/F#/VB expression, statement block or program. Put an end to those hundreds of Visual Studio Console projects cluttering your source folder and join the revolution of LINQPad scripters and incremental developers. TMetric  :  TMetric is a work time tracker for freelancers, agencies, and companies. Light interface with great control over time intervals and projects’ budgets. Flexible billable rates and crystal clear reporting. Transparent team monitoring and lots of integrations. Second Monitor :   While you can accomplish most tasks with only one monitor, two monitors allow you to accomplish the same tasks in a fraction of the time.