C#C
C#3y ago
31 replies
Owl

❔ Learning C#, and curious about advanced return statements...

I'm jumping right into the depts and wish to return a new object of 'Buffer' type and construct it with lambda.
The instruction should be to create Buffer object and write .txt file to Buffer.contents.
Can someone teach me how to make that happen with a single statement?

using System.IO;

public struct Buffer
{
    public string[] contents;
}

public Buffer ReadFromFile(System.IO.File _file)
{
    return &Buffer();() => _file.ToString();
}


(new to C#, so please be gentle)
Was this page helpful?