This one’s an obvious error really – but it’s still undocumented, and thus qualifies for a blog entry. I guess once __arglist was dropped from the standard documentation, all its associated error messages were dropped too.
Compiler Error CS0226
Error Message
An __arglist expression may only appear inside of a call or new expression
Example
The following sample generates CS0226
// error CS0226
__arglist("apples", "pears");
Expected usage
static void Foo(Object obj, __arglist)
{
Console.WriteLine("First arg : {0}", obj);
ArgIterator iterator = new ArgIterator(__arglist);
for (int i = iterator.GetRemainingCount(); i > 0; i--)
{
Console.WriteLine(TypedReference.ToObject(iterator.GetNextArg()));
}
}
. . .
Foo(x, __arglist("apples", "pears"));
0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment