문제

I've really tried to solve this on my own, and it seems so simple but hopefully with the right pointer I can work out the rest of what I need, but...

How can I generate the following code with Rosyln:

var entity = new Entity
{
    Name = "A",
    Value = 12
};

I know SyntaxFactory.InitializerExpression is involved somewhere, but I'm just lost!

도움이 되었습니까?

해결책

The Roslyn Quoter tool is very handy for things like this:

roslynquoter.azurewebsites.net.

Now that it assumes you have an entire valid file

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top