I'm testing some code in C# from Visual Studio Express 2008:
delegate void Hm(int k);
static void Main(string[] args)
{
char[] m = new char[10];
m[0] = 'H'; m[5] = 'M';
m[1] = 'o'; m[6] = 'u';
m[2] = 'l'; m[7] = 'n';
m[3] = 'a'; m[8] = 'd';
m[4] = ' '; m[9] = 'o';
unsafe { fixed (char* p = m) { Hm H = (k) => recurd(k, p); H(0); } }
Console.ReadLine();
}
static unsafe int recurd(int i, char* p)
{
Console.WriteLine(p[i]);
if (i == 10) return 0; else return recurd(i + 1, p);
}
It compiles perfectly, but if I make a little change in the "recurd" function:
static unsafe int recurd(int i, char* p)
{
Console.WriteLine(p[i]);
i == 10 ? 0 : recurd(i + 1, p);
// if (i == 10) return 0; else return recurd(i + 1, p);
}
I got an error that says "Just the expressions of object assignment, call, increment, decrement and new can be used as instruction" (It's a translation from spanish).
Why do I get this error? How can I fix it?