Skip to content

Instantly share code, notes, and snippets.

@controlflow
Last active December 5, 2016 09:50
Show Gist options
  • Save controlflow/2f388683c4cd990a0be60b97aead7eb6 to your computer and use it in GitHub Desktop.
Save controlflow/2f388683c4cd990a0be60b97aead7eb6 to your computer and use it in GitHub Desktop.
using System;
class ArgListFun {
static void Main() {
var arg2 = 1;
string arg3;
var arg1 = M(__arglist(123, ref arg2, out arg3));
Console.WriteLine(arg1); // 123
Console.WriteLine(arg2); // 43
Console.WriteLine(arg3); // "abc"
}
static int M(__arglist) {
var iterator = new ArgIterator(__arglist);
var arg1 = __refvalue(iterator.GetNextArg(), int);
__refvalue(iterator.GetNextArg(), int) += 42;
__refvalue(iterator.GetNextArg(), string) = "abc";
return arg1;
}
}
@dadhi
Copy link

dadhi commented Dec 5, 2016

Is it C# 7 ?

@flaticols
Copy link

flaticols commented Dec 5, 2016

__arglist, __refvalue,__makeref and __reftype keywords available in earlier versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment