Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP's With...EndWith equivalent in C# ?
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01216132
Message ID:
01216653
Vues:
17
Hi, Fabio!

>Despite all the reasons already put here, I think that such a construction in C# would cause some major legibility problems. The main reason that leads me to think so is the fact that in C# any line break character present in the source file is normalized into a regular space by the compiler. In VB.NET the statement must be terminated on the same line or explicitly be broken with the "_" (underscore) char.
>
>Having said that, in a perfect world, a simple "with" construction in C# would be like that:
>
>
>TextBox field = new TextBox();
>with (field)
>{
>    .Text = "foo";
>}
>
>
>But my immagination keeps trying to convince me that things like the following would be easily found:
>
>
>TextBox field = new TextBox();
>with (field)
>{
>    .
>
>
>Text = "foo";
>}
>
>
>Where is "Wally" <g>? Ops... where is the dot?

Well, as Hugo pointed out, this is something beyond the with/endwith problem. My question is what's the value of with/endwith in C#? I can't really see any. Instead, C# has powerful and meaningful constructions like "using", which provides an execution context for a disposable resource, simplifying the error handling code VERY much.

Regards,
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform