List of Anonymous types in C#

The given link provides a very simple and easy approach for defining and using a list of anonymous types. http://kirillosenkov.blogspot.com/2008/01/how-to-create-generic-list-of-anonymous.html
This saves a lot of trouble of defining a new type for just onetime usage.

Advertisements

Capturing Screen as Bitmap Image in C#

The easiest way for taking screen snapshot in C# is given in the following code.

            Rectangle workingArea = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;
            Bitmap screenShot = new Bitmap(workingArea.Width, workingArea.Height);

            Graphics gr = Graphics.FromImage(screenShot);

            gr.CopyFromScreen(0, 0, 0, 0, workingArea.Size);

            return screenShot;

In the above code, first a rectangle is created which equal to the size of the primary screen.
Then a bitmap is created which will store the pixels for the snapshot image.
The Graphics object is created which will store and perform operations on the bitmap object we just created.
The CopyFromScreen function captures the screen, copying all the color pixels to the bitmap of the Graphics object. The parameters to the function are about from where the copying will start in the source and to where it will go in the target. The first two are x and y are starting coordinates for the source and the third and fourth are about the starting coordinates for the target location. The last parameter is about the size of the rectangular region which will be copied, which consist of width and height.

Love and Programming

Once a friend told me that when anyone falls in love, then s/he thinks all the time about the lover. I thought about it a little and then come up with the following short story after putting myself in the situation.

I am a programmer. I have 45 minutes walk back to my place at evening. I like it to have sticky problems and solving them. I think about different stuff on that walk and i enjoy this. one day i felt that i fell in love with my coworker. She is a pretty girl and very nice. She is like to be respected and loved. I was in love. i did not know how and why, but i was. It had all the symptoms of true love, and i started to like the junky poetry on SMSes. I felt the true love, the itch, you know! I just don’t know anything else.
One day i thought all the way about her. next day again. But at the end, i got bored of it. What the hell! I have no other thing to think about. At the end of the day, i wasn’t happy like when i solve some tricky problem or have an amazing idea. i missed the thinking i have on the walk about programming problems i have and newer ideas. I got depressed. I stopped thinking about her. I wanted to do programming and the true love thing might take this away from me. it might give me temporary joy but will take the happiness and the feeling away i have when i am a true programmer.

Am i mis-interpreting the love thing or do programmers really don’t want to get in that shit.