Inconsistent syntax c# ?

Posted by maxp on Stack Overflow See other posts from Stack Overflow or by maxp
Published on 2010-04-16T15:29:46Z Indexed on 2010/04/16 15:33 UTC
Read the original article Hit count: 361

Filed under:
|
private string[] GetRoles()
{
    string[] foo = {"Test"};
    return foo;       
}

The above compiles, but...

private string[] GetRoles()
{
    return {"Test"};        
}

Does not.

Replacing it with:

return new string[] { "Test" };    

Will obviously compile though. Is this inconsistancy or am i being stupid, or am i just wrong :S.

© Stack Overflow or respective owner

Related posts about c#

Related posts about syntax