<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FLanguage_Basics%2FFinally</id>
		<title>Csharp/CSharp Tutorial/Language Basics/Finally - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FLanguage_Basics%2FFinally"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Language_Basics/Finally&amp;action=history"/>
		<updated>2026-04-29T20:33:41Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Language_Basics/Finally&amp;diff=6556&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Language_Basics/Finally&amp;diff=6556&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:53Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Language_Basics/Finally&amp;diff=6557&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Language_Basics/Finally&amp;diff=6557&amp;oldid=prev"/>
				<updated>2010-05-26T12:19:55Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Dispose a StreamWriter in finally block==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
public sealed class MainClass&lt;br /&gt;
{&lt;br /&gt;
    static void Main(){&lt;br /&gt;
        StreamWriter sw = new StreamWriter(&amp;quot;Output.txt&amp;quot;);&lt;br /&gt;
        try {&lt;br /&gt;
            sw.WriteLine( &amp;quot;This is a test of the emergency dispose mechanism&amp;quot; );&lt;br /&gt;
        }&lt;br /&gt;
        finally {&lt;br /&gt;
            if( sw != null ) {&lt;br /&gt;
                ((IDisposable)sw).Dispose();&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==finally block is always executed even if an exception was thrown in the try==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
class Processor&lt;br /&gt;
{&lt;br /&gt;
    public void ProcessFile()&lt;br /&gt;
    {&lt;br /&gt;
        FileStream f = new FileStream(&amp;quot;wrongNameFile.txt&amp;quot;, FileMode.Open);&lt;br /&gt;
        try&lt;br /&gt;
        {&lt;br /&gt;
            StreamReader t = new StreamReader(f);&lt;br /&gt;
            string    line;&lt;br /&gt;
            while ((line = t.ReadLine()) != null)&lt;br /&gt;
            {&lt;br /&gt;
                Console.WriteLine(line);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        finally&lt;br /&gt;
        {&lt;br /&gt;
            f.Close();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class Test&lt;br /&gt;
{&lt;br /&gt;
    public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        Processor processor = new Processor();&lt;br /&gt;
        try&lt;br /&gt;
        {&lt;br /&gt;
            processor.ProcessFile();&lt;br /&gt;
        }&lt;br /&gt;
        catch (Exception e)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;Exception: {0}&amp;quot;, e);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Exception: System.IO.FileNotFoundException: Could not find file &amp;quot;C:\Java_Dev\WEB\dev\CSharp\wrongNam&lt;br /&gt;
eFile.txt&amp;quot;.&lt;br /&gt;
File name: &amp;quot;C:\Java_Dev\WEB\dev\CSharp\wrongNameFile.txt&amp;quot;&lt;br /&gt;
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)&lt;br /&gt;
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean&lt;br /&gt;
 useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, St&lt;br /&gt;
ring msgPath, Boolean bFromProxy)&lt;br /&gt;
   at System.IO.FileStream..ctor(String path, FileMode mode)&lt;br /&gt;
   at Processor.ProcessFile()&lt;br /&gt;
   at Test.Main()&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Using finally==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Sometimes you can define a block of code that will execute when a try/catch block is left.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;The general form of a try/catch that includes finally is shown here:&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;try {&lt;br /&gt;
        // block of code to monitor for errors&lt;br /&gt;
    }&lt;br /&gt;
    catch (ExcepType1 exOb) {&lt;br /&gt;
        // handler for ExcepType1 &lt;br /&gt;
    }&lt;br /&gt;
    catch (ExcepType2 exOb) {&lt;br /&gt;
        // handler for ExcepType2 &lt;br /&gt;
    }&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    .&lt;br /&gt;
    finally {&lt;br /&gt;
        // finally code&lt;br /&gt;
    }&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>