Tag Archives: C#

How to check for duplicates

Say you have an IEnumerable<T> of some sort and you want to check if it contains any duplicates. How do you do that? Terrible solution I needed to do this a while ago and the first solution that hit me wasn’t exactly good. Linq has method called Distinct, which returns the distinct items in a sequence (weeds [...]
Posted in Software Development | Also tagged , , | Leave a comment

How to test asynchronous events

The other day I had to test that an event was raised after some asynchronous work had been done. And since I currently am a total test newbie, this was a new thing for me. Say we have this simple shell of a class: public class Worker {     public event EventHandler<eventargs> Done;     public void Start()   [...]
Posted in Software Development | Also tagged , , , | Leave a comment

Generics and checking for null

When writing C#, in Visual Studio, using generics… have you ever tried checking for null? I have always found that a bit of a hassle. Say we have this method which returns the subject if it is not null, and the result of a createNew() function if it is null. public static T NewIfNull<t>(this T subject, [...]
Posted in Software Development | Also tagged , | Leave a comment

Project Euler: Problem 25

The Fibonacci sequence is defined by the recurrence relation: , where and . Hence the first 12 terms will be: … The 12th term, , is the first term to contain three digits. What is the first term in the Fibonacci sequence to contain 1000 digits?
Posted in Project Euler, Software Development | Also tagged , , | Leave a comment

Project Euler: Problem 16

and the sum of its digits is. What is the sum of the digits of the number ?
Posted in Project Euler, Software Development | Also tagged | Leave a comment

The Art of Unit Testing

Have you gone through three years of computer science bachelor degree fun (or anything similar) and pretty much not heard a word about testing? Or have you heard from all your teachers that testing is extremely important, but never learned how to even write one? That has been the case for me. Testing is important, [...]
Posted in Reviews, Software Development | Also tagged , , | 3 Comments

The Sieve of Atkin in C#

I have previously written about the Sieve of Eratosthenes, which is an algorithm for finding primes. This algorithm worked very well for most of the prime related Euler Problems. However, for one of them it just didn’t do it. Well, it did it, but it did it kind of slow. The problem was to calculate [...]
Posted in Software Development | Also tagged , | 1 Comment
  • Twitter Facebook YouTube last.fm LinkedIn Google vimeo Technorati RSS feed
  • This would be meGreetings! I am Torleif Berger, 24 years old, a Seventh-Day Adventist and currently working as a software developer. Otherwise, not much to tell. Although I do juggle a bit...