Uncategorized
Craps Simulation
I’ve been working on a craps simulator in c# lately, to figure out how to maximize my chance of leaving the casino with more money than I came in with. At this point it seems that you have the best Read more…
I’ve been working on a craps simulator in c# lately, to figure out how to maximize my chance of leaving the casino with more money than I came in with. At this point it seems that you have the best Read more…
My good friend JP for letting me know this domain was available again. You rox d00d!
Another question I was asked yesterday and had difficulty answering is: when would you use an abstract class, and when would you use an interface? The obvious answer is, you use an abstract class when you need to provide some Read more…
Today in an interview I was asked, when would you use composition and when would you use inheritance? I struggled with this question, not because I have never considered it, but because the interviewer was asking me to translate abstract Read more…
If you are using Entity Framework and you want your data store to generate some values automatically (e.g., to automatically fill a CreateDate with the date and time that the object was created), you should configure the field as Store-Generated. Read more…
There was a thread on StackOverflow recently about an interview question where the candidate was asked to write a program that will always deadlock. Eric Lippert’s example is shorter than mine, but I think my answer (which I’m posting here Read more…
If you're working frequently with the connected layer, the previous post would be sufficient for most purposes (given adequate knowledge of SQL), if perhaps a little awkward. The following information might make your life a little bit easier. (more…)
In order to send queries to the database, you need an instance of a DbCommand-derived type. This instance is obtained from invoking the CreateCommand method on an instance of DbProviderFactory for the database provider in question, e.g.: 1 2 3 Read more…
Extension methods are methods that are added to existing compiled types. These are useful for adding new members to classes in the BCL or in assemblies for which source code is not available. However, extension methods can also be useful because they can be called on null references. For instance, an immutable Stack(of T) implementation might contain a head of type T and a tail of type Stack(of T). How do you create an empty stack if T is allowed to be a non-nullable value type? (more…)
When comparing two instances of a reference type for equality (in value, not checking to see if they are the same instance), rather than using .Equals it’s best to use an IComparer. In a generic type, if nothing is known Read more…