Browse by Tags

All Tags » C# (RSS)

Where do you benefit from dynamic typing?

Disclaimer: I don't want this to become a flame war in the comments. I'm coming from a position of ignorance, and well aware of it. While I'd like this post to provoke thought , it's not meant to be provocative in the common use of the...
Posted by skeet | 40 comment(s)
Filed under: , ,

Just how spiky is your traffic?

No, this isn't the post about dynamic languages I promise. That will come soon. This is just a quick interlude. This afternoon, while answering a question on Stack Overflow 1 about the difference between using an array and a Dictionary<string,...
Posted by skeet | 9 comment(s)
Filed under: , ,

Noda Time gets its own blog

I've decided it's probably not a good idea to make general Noda Time posts on my personal blog. I'll still post anything that's particularly interesting in a "general coding" kind of way here, even if I discover it in Noda Time...
Posted by skeet | 3 comment(s)
Filed under: , ,

Noda Time is born

There was an amazing response to yesterday's post – not only did readers come up with plenty of names, but lots of people volunteered to help. As a result, I'm feeling under a certain amount of pressure for this project to actually take shape...
Posted by skeet | 44 comment(s)
Filed under: , ,

What's in a name (again)?

I have possibly foolishly decided to stop resisting the urge to port Joda Time to .NET. For those of you who are unaware, "use Joda Time" is almost always the best answer to any question involving "how do I achieve X with java.util.Date...
Posted by skeet | 54 comment(s)
Filed under: , ,

Revisiting randomness

Almost every Stack Overflow question which includes the words "random" and "repeated" has the same basic answer. It's one of the most common "gotchas" in .NET, Java, and no doubt other platforms: creating a new random...

Contract classes and nested types within interfaces

I've just been going through some feedback for the draft copy of the second edition of C# in Depth. In the contracts section, I have an example like this: [ContractClass( typeof (ICaseConverterContracts))] public   interface ICaseConverter {...
Posted by skeet | 9 comment(s)
Filed under: , , ,

Migrating from Visual Studio 2010 beta 1 to beta 2 – solution file change required

Having installed Visual Studio 2010 beta 2 on my freshly-reinstalled netbook (now with Windows 7 and and SSD – yummy) I found that my solution file from Visual Studio 2010 beta 1 wasn’t recognised properly : double-clicking on the file didn’t do anything...
Posted by skeet | 3 comment(s)

Iterating atomically

The IEnumerable<T> and IEnumerator<T> interfaces in .NET are interesting. They crop up an awful lot, but hardly anyone ever calls them directly - you almost always use a foreach loop to iterate over the collection. That hides all the calls...

Generic collections - relegate to an appendix?

(I tweeted a brief version of this suggestion and the results have been overwhelmingly positive so far, but I thought it would be worth fleshing out anyway.) I'm currently editing chapter 3 of C# in Depth. In the first edition, it's nearly 48...
Posted by skeet | 16 comment(s)
Filed under: ,

MVP no more

It's with some sadness that I have to announce that as of the start of October, I'm no longer a Microsoft MVP. As renewal time came round again, I asked my employer whether it was okay for me to renew, and was advised not to do so. As a result...
Posted by skeet | 84 comment(s)
Filed under: ,

An object lesson in blogging and accuracy; was: Efficient "vote counting" with LINQ to Objects - and the value of nothing

Well, this is embarrassing. Yesterday evening, I excitedly wrote a blog post about an interesting little idea for making a particular type of LINQ query (basically vote counting) efficient. It was an idea that had occurred to me a few months back, but...
Posted by skeet | 11 comment(s)
Filed under: , ,

API design: choosing between non-ideal options

So, UnconstrainedMelody is coming on quite nicely. It now has quite a few useful options for flags enums, "normal enums" and delegates. However, there are two conflicting limitations which leave a couple of options. (Other related answers on...
Posted by skeet | 10 comment(s)
Filed under: , ,

Generic constraints for enums and delegates

As most readers probably know, C# prohibits generic type constraints from referring to System.Object, System.Enum, System.Array, System.Delegate and System.ValueType. In other words, this method declaration is illegal: public static T[]GetValues<T>...
Posted by skeet | 54 comment(s)

Recent activities

It's been a little while since I've blogged, and quite a lot has been going on. In fact, there are a few things I'd have blogged about already if it weren't for "things" getting in the way. Rather than writing a whole series...

The "dream book" for C# and .NET

This morning I showed my hand a little on Twitter . I've had a dream for a long time about the ultimate C# book. It's a dream based on Effective Java , which is my favourite Java book, along with my experiences of writing C# in Depth. Effective...
Posted by skeet | 33 comment(s)
Filed under: , ,

Tricky decisions... Code Contracts and Parallel Extensions in C# in Depth 2nd edition

I'd like some feedback from readers, and I suspect my blog is the simplest way to get it. I'm currently writing chapter 15 of C# in Depth, tentatively about Code Contracts and Parallel Extensions. The problem is that I'm 15 pages in, and I...
Posted by skeet | 83 comment(s)
Filed under: , ,

Evil Code of the Day: variance and overloading

(Note that this kind of breakage was mentioned a long time ago in Eric Lippert's blog , although not in this exact form.) Whenever a conversion becomes available where it wasn't before, overload resolution can change its behaviour. From C# 1 to...
Posted by skeet | 6 comment(s)
Filed under: , ,

Faking COM to fool the C# compiler

C# 4 has some great features to make programming against COM components bearable fun and exciting. In particular: PIA linking allows you to embed just the relevant bits of the Primary Interop Assembly into your own assembly, so the PIA isn't actually...
Posted by skeet | 1 comment(s)

Evil code of the day

At a glance, this code doesn't look particularly evil. What does it do though? Compile it with the C# 4.0b1 compiler and run it... using System; class Base {     public   virtual   void Foo( int x, int y)    ...
Posted by skeet | 35 comment(s)
Filed under: ,
More Posts Next page »