"using" operator in C#

4 posts, 0 answers
  1. Valeri Hristov
    Valeri Hristov avatar
    40 posts
    Member since:
    Dec 2003

    Posted 30 Mar 2007 Link to this post

    The converter is not able to convert code like this:

    using (StreamWriter file = File.AppendText("C:\\temp\\file.txt"))
    {
        file.WriteLine("Date: {0}", DateTime.Now);
    }

    which should become something like this (I translated the C# code to that format by hand and then threw it in the converter):

    Dim file As StreamWriter = Nothing
    Try
        file = File.AppendText("C:\temp\file.txt")
        file.WriteLine("Date: {0}", DateTime.Now)
    Finally
        If file <> Nothing Then
            file.Dispose()
        End If
    End Try
  2. Todd Anglin
    Todd Anglin avatar
    2040 posts
    Member since:
    Aug 2005

    Posted 30 Mar 2007 Link to this post

    Valeri-

    I'm not sure that the converter can make that judgment since the "Using" syntax is also valid in VB (just like the Try..Catch syntax is valid in C#). Microsoft introduced the Using syntax to VB in version 2.0, which means I think the converters output is correct.

    What do you think?

    Thanks~
    Todd
  3. Valeri Hristov
    Valeri Hristov avatar
    40 posts
    Member since:
    Dec 2003

    Posted 02 Apr 2007 Link to this post

    My bad, I made a typo the first time, hence the error :)

    However, I am always getting the following error:
  4. Todd Anglin
    Todd Anglin avatar
    2040 posts
    Member since:
    Aug 2005

    Posted 02 Apr 2007 Link to this post

    Valeri-

    Thanks for brining my attention to the JavaScript error. The error was not happening in my dev environment, so I refreshed the production files and that seemed to clear things up. You should not run into that Tab Extender error any more.

    Thanks~
    Todd
Back to Top