Do you use goto in C#?
Looking through the code for the SmtpClient.Send method in Reflector and found this snippet:
{
{
"SmtpPickupDirectoryDoesnotSupportSsl"));
break;
{
"SmtpPickupDirectoryDoesnotSupportSsl"));
goto Label_021C;
MailWriter fileMailWriter = this.GetFileMailWriter(
this.PickupDirectoryLocation);
goto Label_025D;
IisPickupDirectory.GetPickupDirectory());
goto Label_025D;
fileMailWriter = this.transport.SendMail((message.Sender != null) ?
message.Sender : message.From, recipients,
message.BuildDeliveryStatusNotificationString(),
out exception);
message.Send(fileMailWriter, this.DeliveryMethod != SmtpDeliveryMethod.Network);
fileMailWriter.Close();
this.transport.ReleaseConnection();
if ((this.DeliveryMethod == SmtpDeliveryMethod.Network) && (exception != null))
{
I've always been taught to avoid goto like the plague, and it's something I've followed for years. I've never even considered it to be an option when writing code.
Thinking about it though, I did read an article a few years ago (which I can't find now) which said you could credibly use gotos only if you used it to jump down code, and not up: a rule that is stuck to here.
The thing is, I know this code can be written without using goto. But also, it might not be as readable as it is now.
I'm conflicted. But I'm sticking to the "no goto" rule until someone can come up with an example that really can't be coded without using a goto.