c#

c#

Monkeypatching For Humans

Although I love strings, sometimes the String class can break your heart. For example, in C#, there is no String.Left() function. Fair enough; we can roll up our sleeves and write our own function lickety-split: public static string Left(string s, int len) { if (len == 0 || s.Length == 0)

By Jeff Atwood ·
Comments

c#

Department of Declaration Redundancy Department

I sometimes (often, actually) regress a few years mentally and forget to take advantage of new features afforded by the tools I'm using. In this case, we're using the latest and greatest version of C#, which offers implicitly typed local variables. While working on Stack Overflow,

By Jeff Atwood ·
Comments

c#

Productivity Tip: Upgrade Your Pentium 4

In C# and the Compilation Tax, several commenters noted that they have "fast dual-core computers", and yet background compilation performance was unsatisfactory for them on large projects. It's entirely possible that this is Visual Studio's fault. However, I'd like to point out

By Jeff Atwood ·
Comments

c#

C# and the Compilation Tax

Over the last four years, I've basically given up on the idea that .NET is a multiple language runtime. * The so-called choice between the two most popular languages, C# and VB.NET, is no more meaningful than the choice between Coke and Pepsi. Yes, IronPython and IronRuby are

By Jeff Atwood ·
Comments

filepaths

Filesystem Paths: How Long is Too Long?

I recently imported some source code for a customer that exceeded the maximum path limit of 256 characters. The paths in question weren't particularly meaningful, just pathologically* long, with redundant subfolders. To complete the migration, I renamed some of the parent folders to single character values. This made

By Jeff Atwood ·
Comments

programming languages

Computer Languages aren't Human Languages

Though I've become agnostic about the utterly meaningless non-choice between VB.NET and C#, the inherited syntax of C leaves a lot to be desired, in my opinion. And not just in the case sensitivity department. Daniel Appleman, in his excellent e-book, VB.NET or C#, Which to

By Jeff Atwood ·
Comments

c#

The Last Configuration Section Handler.. Revisited

If you need to store a little bit of state-- in your configuration file, or on disk-- nothing is faster than some quick and dirty serialization. Or as I like to call it, stringization. In late 2004, I wrote about The Last Configuration Section Handler, which does exactly this for

By Jeff Atwood ·
Comments

c#

Compiler, It Hurts When I Do This

Here's a question that recently came up on an internal mailing list: how do I create an enum with a name that happens to be a c# keyword? I immediately knew the answer for VB.net; you use brackets to delimit the word. Public Enum test [Public] [Private]

By Jeff Atwood ·
Comments

c#

C# Snippet Parity

Microsoft recently released a complete set of C# code snippets for Visual Studio 2005. This brings C# to parity with VB.NET, which had many more code snippets "in the box". Unfortunately, Microsoft's installation strategy for these new snippets leaves a lot to be desired. You

By Jeff Atwood ·
Comments

.net

Choosing between .NET Pepsi and .NET Coke

I've increasingly come to believe that the debate between C# and VB.NET is a red herring. Choosing between C# and VB.NET isn't a meaningful choice. It's like choosing between .NET Pepsi and .NET Coke. Either way, you're getting a cola

By Jeff Atwood ·
Comments

html cleaning

Cleaning Word's Nasty HTML

I recently wrote a Word 2003 document that I later turned into a blog post [http://blogs.vertigosoftware.com/jatwood/archive/2006/01/06/Guidelines_and_Tips_for_Pure_CSS_Layouts.aspx] . The transition between Word doc and HTML presented some problems. Word offers two HTML options in its save

By Jeff Atwood ·
Comments

.net

A Stopwatch Class for .NET 1.1

The first rule of performance testing is to measure, then measure again, then measure one more time just to be sure. NET 2.0 adds a handy Diagnostics.Stopwatch [http://msdn2.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx] which is perfect for this kind of ad-hoc precision timing. A

By Jeff Atwood ·
Comments