With Block in C#

By Michael Flanakin @ 7:05 PM :: 197 Views :: 0 Comments :: (Open), .NET :: Digg it!

This isn't new, but I had to mention it. Since the inception of C#, I have wanted an equivalent to the VB with block. I believe I've heard that it won't be done, but that's not going to stop me from hoping. The idea is simple and it shouldn't affect the IL code that's generated from C#. This is merely a tool in which a developer could speed up development a bit.

Client client = new Client();
with (client)
{
    .FirstName = "Michael";
    .LastName = "Flanakin";
    .Coolness = CoolFactor.ToTheMax;
}

...should compile to...

Client client = new Client();
client.FirstName = "Michael";
client.LastName = "Flanakin";
client.Coolness = CoolFactor.ToTheMax;

I can see maintainability issues with a feature like this, but there are potential maintainability issues with the misuse or overuse of any tool.

Ratings

Comments

Currently, there are no comments. Be the first to post one!
Click here to post a comment



Archives Archives

Categories Categories

Related Links Related Links