void Nish(char* szBlog);

Nish’s thoughts on MFC, C++/CLI and .NET

void Nish(char* szBlog); header image 2

Undocumented compiler error CS0224

February 26th, 2010 · No Comments

A fellow CPian leppie had posted about an undocumented C# error he got (error CS0224) and asked if anyone could reproduce the error (back in Dec 2009). For fun I played with the compiler and managed to reproduce the error. That gave me the idea of blogging about this and other such undocumented errors. Of course the moment I blog about it, it ceases to become undocumented by definition. Also by undocumented, I mean undocumented on MSDN. It may have been blogged on or written about elsewhere, though I do intend to use Google and Bing to try and make sure it’s not a commonly known error. I start off with leppie’s error of CS0224.

As of today (Feb 26, 2010) VS 2008′s MSDN documentation jumps from CS0221 to CS0225, and VS 2010′s MSDN documentation jumps from CS0201 to CS0229. I don’t know why VS 2010 decided to drop those extra error codes, but then this is the RC documentation, and maybe the RTM version will add back those that were documented in VS2008. Anyway enough with the talk and on to the error.

Compiler Error CS0224

Error Message

A method with vararg cannot be generic, be in a generic type, or have a parameter array

Example

The following sample generates CS0224

// error CS0224
static void Foo<T>(T t, __arglist) { }

Correct way

You could rewrite the method in one of the following two ways to get the equivalent functionality :

static void Foo<T>(T t, params object[] args) { }

or

static void Foo(Object obj, __arglist)  { }

Tags: C#/.NET

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment