GOTO will never die

Yesterday i hade a discussion in the forums of the german developer portal www.devtrain.de about language diffrences between C# and VB.NET.
Yes- the same old we hade 100 times bevor. BUT i said, "after the GOTO was removed in vb.net...". The other part told me that he believe GOTO is still in Visual Studio 2003. Bohh - i was surprised.
Following the Hannes pattern, believe nothing except you checked it yourself, i tryed to type GOTO. And what should i say, its true, GOTO is still alive.

goto ende

ende:

Wow!

The next step was to try the same ( with a small hope that it will not work) in Visual Studio 2005.
And the result was quite fancy. Not only GOTO worked well, also intellisense does a great job.

Then i tryed my own for-next loop ;-)
 

Dim i As Double
anfang:
        i = i + 1
        If i < 200000000 Then
            GoTo anfang
        End If

Yes VB.NET is OOP!

3 Comments

  • Actually, C# also has it :-s

  • Do I have one hell of a surprise for you!

    Have you ever tried using goto in C#?

    Try it!

    I wish people will stop this sh!t of which language is the best, I'm a C# guy myself, personal preference, but I give training classes in VB.NET and have found that if you have a VB background you tend to get into .NET faster with VB.NET as you understand the basic syntax already. And for office development VB.NET is just better! period, because it allows optional parameters and the code looks a bit cleaner.

    At the end of the day you need to use what suits the situation. Remember in .NET the ultimate language is MSIL and not VB or C# or J# etc... So in 99% of the situations the code from any .NET language executes exactly the same.

  • i got the following sample by email

    private void AddNewColoumn(){

    int iColCount = this._mytable.NewSchemaTable.Rows.Count + 1;

    coltest:

    string strcolname = &quot;New_Column_&quot; + iColCount.ToString();

    DataColumn dc = new DataColumn(strcolname);

    try{

    this._mytable.Columns.Add(dc);

    this._tableDefChanged = true;

    }

    catch{

    iColCount++;

    goto coltest;

    }





    //Fill the DBDataType HT

    if( this._mytable.DbDataType == null ){

    this._mytable.DbDataType = new Hashtable();

    }

    this._mytable.DbDataType.Add(strcolname, &quot;char&quot;);

    DataRow dr = this._mytable.NewSchemaTable.NewRow();

    dr[&quot;ColumnName&quot;] = strcolname;

    dr[&quot;DataType&quot;] = &quot;char&quot;;

    dr[&quot;ColumnSize&quot;]= 10;

    dr[&quot;AllowDBNull&quot;] = true;

    if ( this._newtable ){

    dr[&quot;Identity&quot;] = false;

    dr[&quot;IdentitySeed&quot;] = 0;

    dr[&quot;IdentityIncrement&quot;] = 1;

    }

    this._mytable.NewSchemaTable.Rows.Add(dr);

    this.FillTableListView();

    //this._hasChanges = true;

    }

Comments have been disabled for this content.