Browse by Tags

All Tags » CSharpDev (RSS)

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)

For vs Foreach on arrays and lists

As promised earlier in the week , here are the results of benchmarking for and foreach . For each of int and double , I created an array and a List<T> , filled it with random data (the same for the list as the array) and ran each of the following...
Posted by skeet | 23 comment(s)

Benchmarking made easy

While I was answering a Stack Overflow question on the performance implications of using a for loop instead of a foreach loop (or vice versa) I promised to blog about the results - particularly as I was getting different results to some other posters...
Posted by skeet | 5 comment(s)

Designing LINQ operators

I've started a small project (I'll post a link when I've actually got something worthwhile to show) with some extra LINQ operators in - things which I think are missing from LINQ to Objects, basically. (I hope to include many of the ideas...
Posted by skeet | 16 comment(s)

You don't have to use query expressions to use LINQ

LINQ is clearly gaining a fair amount of traction, given the number of posts I see about it on Stack Overflow . However, I've noticed an interesting piece of coding style: a lot of developers are using query expressions for every bit of LINQ they...
Posted by skeet | 18 comment(s)

Value types and parameterless constructors

There have been a couple of questions on StackOverflow about value types and parameterless constructors: Structure vs Class in C# Why can’t I define a default constructor for a struct in .NET I learned quite a bit when answering both of these. When a...

Redesigning System.Object/java.lang.Object

I've had quite a few discussions with a colleague about some failures of Java and .NET. The issue we keep coming back to is the root of the inheritance tree. There's no doubt in my mind that having a tree with a single top-level class is a good...

The Snippy Reflector add-in

Those of you who've read C# in Depth will know about Snippy - a little tool which makes it easy to build complete programs from small snippets of code. I'm delighted to say that reader Jason Haley has taken the source code for Snippy and built...
Posted by skeet | 9 comment(s)

Copenhagen C# talk videos now up

The videos from my one day talk about C# in Copenhagen are now on the MSDN community site . There are eight sessions, varying between about 25 minutes and 50 minutes in length. I haven't had time to watch them yet, but when I do I'll submit brief...

.NET 4.0's game-changing feature? Maybe contracts...

Update: As Chris Nahr pointed out, there's a blog post by Melitta Andersen of the BCL team explaining this in more detail. Obviously I've been looking at the proposed C# 4.0 features pretty carefully, and I promise I'll blog more about them...
Posted by skeet | 12 comment(s)

C# 4.0: dynamic<T> ?

I've not played with the VS2010 CTP much yet, and I've only looked briefly at the documentation and blogs about the new C# 4.0 dynamic type, but a thought occurred to me: why not have the option of making it generic as a way of saying "I...

DeveloperDeveloperDeveloper: Registration now open (hurry!)

The registration page for DeveloperDeveloperDeveloper Day 2008 (Reading, November 22nd) is now open. In the past this has been heavily oversubscribed, so if you want to come you'll need to register quickly. I've got a speaking slot in the afternoon...
Posted by skeet | 4 comment(s)

Mapping from a type to an instance of that type

A question came up on Stack Overflow yesterday which I've had to deal with myself before now. There are times when it's helpful to have one value per type, and that value should be an instance of that type. To express it in pseudo-code, you want...

Why boxing doesn't keep me awake at nights

I'm currently reading the (generally excellent) CLR via C# , and I've recently hit the section on boxing. Why is it that authors feel they have to scaremonger about the effects boxing can have on performance? Here's a piece of code from the...
Posted by skeet | 26 comment(s)

Non-nullable reference types

I suspect this has been done several times before, but on my way home this evening I considered what would be needed for the reverse of nullable value types - non-nullable reference types. I've had a play with an initial implementation in MiscUtil...
Posted by skeet | 22 comment(s)

Formatting strings

A while ago I wrote an article about StringBuilder and a reader mailed me to ask about the efficiency of using String.Format instead. This reminded me of a bone I have to pick with the BCL. Whenever we make a call to String.Format , it has to parse the...
Posted by skeet | 19 comment(s)

Lessons learned from Protocol Buffers, part 4: static interfaces

Warning: During this entire post, I will use the word static to mean "relating to a type instead of an instance". This isn't a strictly accurate use but I believe it's what most developers actually think of when they hear the word. A...

Lessons learned from Protocol Buffers, part 3: generic type relationships

In part 2 of this series we saw how the message and builder interfaces were self-referential in order to allow the implementation types to be part of the API. That's one sort of relationship, but in this post we'll see how the two interfaces relate...

Lessons learned from Protocol Buffers, part 2: self-referential generic types

In the first part of this series we saw that a message type and its builder are closely related. The tricky bit comes when we want to define an interface describing messages and builders. Although some members clearly depend on the data being built (the...

Lessons learned from Protocol Buffers, part 1: messages, builders and immutability

My port of the Protocol Buffers project has proved pretty interesting. I thought I'd share some of the lessons I've learned along the way, as well as some of the frustrations at concepts I still can't express in C#. This was originally all...
More Posts Next page »