<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>C# kódok</title>
	<atom:link href="http://users.atw.hu/csharpkodok/" rel="self" type="application/rss+xml" />
	<link>http://users.atw.hu/csharpkodok</link>
	<description>Csharp kódok gyüjteménye</description>
	<lastBuildDate>Fri, 07 Aug 2009 11:44:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>yield használata</title>
		<link>http://users.atw.hu/csharpkodok/?p=145</link>
		<comments>http://users.atw.hu/csharpkodok/?p=145#comments</comments>
		<pubDate>Fri, 07 Aug 2009 11:44:01 +0000</pubDate>
		<dc:creator>nameless</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://users.atw.hu/csharpkodok/?p=145</guid>
		<description><![CDATA[yield használata:

using System;
using System.Collections;
using System.Collections.Generic;
&#160;
namespace Program
{
    class ArrayClass : IEnumerable
    {
        int[] array = { 23, 34, 5643, 56767 };
&#160;
        public IEnumerator GetEnumerator()
        {
     [...]]]></description>
			<content:encoded><![CDATA[<p>yield használata:</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">using System;
using System.Collections;
using System.Collections.Generic;
&nbsp;
namespace Program
{
    class ArrayClass : IEnumerable
    {
        int[] array = { 23, 34, 5643, 56767 };
&nbsp;
        public IEnumerator GetEnumerator()
        {
            for (int i = 0; i &lt; array.Length; i++) //végigpörgetük a tömb elemeit
                yield return array[i]; //visszaadjuk a tömb adott elemét a yield return segítségével
        }
    }
    class MainClass
    {
        public static void Main()
        {
            var myA = new ArrayClass();
&nbsp;
            foreach (var i in myA)
            {
                Console.WriteLine(i);
            }
&nbsp;
            Console.ReadKey();
        }
    }
}</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://users.atw.hu/csharpkodok/?feed=rss2&amp;p=145</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ICloneable</title>
		<link>http://users.atw.hu/csharpkodok/?p=143</link>
		<comments>http://users.atw.hu/csharpkodok/?p=143#comments</comments>
		<pubDate>Fri, 07 Aug 2009 11:43:17 +0000</pubDate>
		<dc:creator>nameless</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://users.atw.hu/csharpkodok/?p=143</guid>
		<description><![CDATA[Klónozható objektumok (ICloneable):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
&#160;
namespace CloneablePoint
{
    public class Point : ICloneable
    {
        public int x, y;
        public Point(int x, int y) { this.x = x; this.y = y; }
    [...]]]></description>
			<content:encoded><![CDATA[<p>Klónozható objektumok (ICloneable):</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
&nbsp;
namespace CloneablePoint
{
    public class Point : ICloneable
    {
        public int x, y;
        public Point(int x, int y) { this.x = x; this.y = y; }
        public Point() { }
&nbsp;
        //Az aktuális objektum máslatát adja vissza
        public object Clone()
        { return new Point(this.x, this.y); }
&nbsp;
        //Az Object.ToString felülbírálása
        public override string ToString()
        { return(string.Format(&quot;x = {0}; y = {1}&quot;,x,y)); }
    }
&nbsp;
    class Program
    {
        static void Main(string[] args)
        {
            //A Clone generikus objektumot ad vissza
            //Eplicit kasztolással olvasható ki a leszármazott típus
            var p3 = new Point(100, 100);
            Point p4 = (Point)p3.Clone();
&nbsp;
            //a p4.x megváltoztatása
            p4.x = 0;
            Console.WriteLine(p3);
            Console.WriteLine(p4);
&nbsp;
            Console.ReadKey();
        }
    }
}</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://users.atw.hu/csharpkodok/?feed=rss2&amp;p=143</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IEnumerable</title>
		<link>http://users.atw.hu/csharpkodok/?p=141</link>
		<comments>http://users.atw.hu/csharpkodok/?p=141#comments</comments>
		<pubDate>Fri, 07 Aug 2009 11:42:29 +0000</pubDate>
		<dc:creator>nameless</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://users.atw.hu/csharpkodok/?p=141</guid>
		<description><![CDATA[Az IEnumerable segít a foreach asználatában.

using System;
using System.Collections; //Ez fontos
&#160;
namespace Program
{
&#160;
    // Az adott osztálynak teljesítenie kell a IEnumerable interfész GEnumerator() metódusát
    class ArrayClass : IEnumerable
    {
        int[] array = { 23, 34, 5643, 56767 };
&#160;
    [...]]]></description>
			<content:encoded><![CDATA[<p>Az IEnumerable segít a foreach asználatában.</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">using System;
using System.Collections; //Ez fontos
&nbsp;
namespace Program
{
&nbsp;
    // Az adott osztálynak teljesítenie kell a IEnumerable interfész GEnumerator() metódusát
    class ArrayClass : IEnumerable
    {
        int[] array = { 23, 34, 5643, 56767 };
&nbsp;
        public IEnumerator GetEnumerator()
        {
           return array.GetEnumerator();
        }
    }
    class MainClass
    {
        public static void Main()
        {
            var myA = new ArrayClass();
&nbsp;
            foreach (var i in myA)
            {
                Console.WriteLine(i);
            }
            Console.ReadKey();
        }
&nbsp;
    }
}</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://users.atw.hu/csharpkodok/?feed=rss2&amp;p=141</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Felsorolható típusok készítése</title>
		<link>http://users.atw.hu/csharpkodok/?p=139</link>
		<comments>http://users.atw.hu/csharpkodok/?p=139#comments</comments>
		<pubDate>Wed, 05 Aug 2009 19:37:15 +0000</pubDate>
		<dc:creator>nameless</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://users.atw.hu/csharpkodok/?p=139</guid>
		<description><![CDATA[Felsorolható típusok készítése (IEnumerator, IEnumerable):
rádió osztály:

using System;
using System.Collections.Generic;
using System.Text;
&#160;
namespace CustomEnumerator
{
  public class Radio
  {
    public void TurnOn(bool on)
    {
      if(on)
        Console.WriteLine(&#34;Jamming...&#34;);
      else
        Console.WriteLine(&#34;Quiet [...]]]></description>
			<content:encoded><![CDATA[<p>Felsorolható típusok készítése (IEnumerator, IEnumerable):</p>
<p>rádió osztály:</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">using System;
using System.Collections.Generic;
using System.Text;
&nbsp;
namespace CustomEnumerator
{
  public class Radio
  {
    public void TurnOn(bool on)
    {
      if(on)
        Console.WriteLine(&quot;Jamming...&quot;);
      else
        Console.WriteLine(&quot;Quiet time...&quot;);
    }
  }
}</pre></div></div>

<p>garage osztály:</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">using System;
using System.Collections.Generic;
using System.Text;
&nbsp;
// Need this for IEnumerator
using System.Collections;
&nbsp;
namespace CustomEnumerator
{
  // Garage contains a set of Car objects.
  public class Garage : IEnumerable
  {
    private Car[] carArray= new Car[4];
&nbsp;
    // Fill with some Car objects upon startup.
    public Garage()
    {
      carArray[0] = new Car(&quot;Rusty&quot;, 30);
      carArray[1] = new Car(&quot;Clunker&quot;, 55);
      carArray[2] = new Car(&quot;Zippy&quot;, 30);
      carArray[3] = new Car(&quot;Fred&quot;, 30);
    }
&nbsp;
    #region IEnumerable Members
&nbsp;
    public IEnumerator GetEnumerator()
    {
      return carArray.GetEnumerator();
    }
&nbsp;
    #endregion
  }
}</pre></div></div>

<p>car osztály:</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">using System;
using System.Collections.Generic;
using System.Text;
&nbsp;
namespace CustomEnumerator
{
  public class Car
  {
    #region Member variables &amp; Constructors
    // Constant for maximum speed.
    public const int MaxSpeed = 100;
&nbsp;
    // Internal state data.
    private int currSpeed;
    private string petName;
&nbsp;
    // Is the car still operational?
    private bool carIsDead;
&nbsp;
    // A car has-a radio.
    private Radio theMusicBox = new Radio();
&nbsp;
    // Constructors.
    public Car() {}
    public Car(string name, int currSp)
    {
      currSpeed = currSp;
      petName = name;
    }
    #endregion
&nbsp;
    #region Properties
    public int Speed
    {
      get { return currSpeed; }
      set { currSpeed = value; }
    }
    public string PetName
    {
      get { return petName; }
      set { petName = value; }
    }	
    #endregion
&nbsp;
    #region Methods
    public void CrankTunes(bool state)
    {
      // Delegate request to inner object.
      theMusicBox.TurnOn(state);
    }
&nbsp;
    // This time, throw an exception if the user speeds up beyond MaxSpeed.
    public void Accelerate(int delta)
    {
      if (carIsDead)
        Console.WriteLine(&quot;{0} is out of order...&quot;, petName);
      else
      {
        currSpeed += delta;
        if (currSpeed &gt;= MaxSpeed)
        {
          carIsDead = true;
          currSpeed = 0;
&nbsp;
          // We need to call the HelpLink property, thus we need
          // to create a local variable before throwing the Exception object.
          Exception ex =
            new Exception(string.Format(&quot;{0} has overheated!&quot;, petName));
          ex.HelpLink = &quot;http://www.CarsRUs.com&quot;;
&nbsp;
          // Stuff in custom data regarding the error.
          ex.Data.Add(&quot;TimeStamp&quot;,
            string.Format(&quot;The car exploded at {0}&quot;, DateTime.Now));
          ex.Data.Add(&quot;Cause&quot;, &quot;You have a lead foot.&quot;);
          throw ex;
        }
        else
          Console.WriteLine(&quot;=&gt; CurrSpeed = {0}&quot;, currSpeed);
      }
    }
    #endregion
  }
}</pre></div></div>

<p>program osztály:</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">using System;
using System.Collections.Generic;
using System.Text;
&nbsp;
using System.Collections;
&nbsp;
namespace CustomEnumerator
{
  // This seems reasonable...
  public class Program
  {
    static void Main(string[] args)
    {
      Console.WriteLine(&quot;***** Fun with IEnumerable / IEnumerator *****\n&quot;);
&nbsp;
      Garage carLot = new Garage();
&nbsp;
      // Hand over each car in the collection?
      foreach (Car c in carLot)
      {
        Console.WriteLine(&quot;{0} is going {1} MPH&quot;,
          c.PetName, c.Speed);
      }
&nbsp;
      Console.WriteLine();
&nbsp;
      // Manually work with IEnumerator.
      IEnumerator i = carLot.GetEnumerator();
      i.MoveNext();
      Car myCar = (Car)i.Current;
      Console.WriteLine(&quot;{0} is going {1} MPH&quot;, myCar.PetName, myCar.Speed);
      Console.ReadLine();
    }
  }
}</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://users.atw.hu/csharpkodok/?feed=rss2&amp;p=139</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interfészhiearchia</title>
		<link>http://users.atw.hu/csharpkodok/?p=137</link>
		<comments>http://users.atw.hu/csharpkodok/?p=137#comments</comments>
		<pubDate>Wed, 05 Aug 2009 19:34:47 +0000</pubDate>
		<dc:creator>nameless</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://users.atw.hu/csharpkodok/?p=137</guid>
		<description><![CDATA[Interfészhiearchia tervezése:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
&#160;
namespace InterfaceHierarchy
{
    public interface IDrawable
    {
        void Draw();
    }
&#160;
    public interface Iprintable : IDrawable
    {
        void Print();
    }
&#160;
 [...]]]></description>
			<content:encoded><![CDATA[<p>Interfészhiearchia tervezése:</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
&nbsp;
namespace InterfaceHierarchy
{
    public interface IDrawable
    {
        void Draw();
    }
&nbsp;
    public interface Iprintable : IDrawable
    {
        void Print();
    }
&nbsp;
    public interface IRenderToMemory : Iprintable
    {
        void Render();
    }
&nbsp;
    public class SuperShape : IRenderToMemory
    {
        public void Draw()
        {
            Console.WriteLine(&quot;Drawing...&quot;);
        }
        public void Print()
        {
            Console.WriteLine(&quot;Printig...&quot;);
        }
        public void Render()
        {
            Console.WriteLine(&quot;Rendering...&quot;);
        }
    }
    public class TwoShape : Iprintable
    {
        public void Draw()
        {
            Console.WriteLine(&quot;Drawing...&quot;);
        }
        public void Print()
        {
            Console.WriteLine(&quot;Printig...&quot;);
        }
    }
&nbsp;
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(&quot;**********SUPERSHAPE*************&quot;);
            var myShape = new SuperShape();
            myShape.Draw();
            myShape.Print();
            myShape.Render();
&nbsp;
            Console.ReadKey();
&nbsp;
            Console.WriteLine(&quot;\n\n************TwoShape*************&quot;);
            var myTwoShape = new TwoShape();
            myTwoShape.Draw();
            myTwoShape.Print();
&nbsp;
            Console.ReadKey();
        }
    }
}</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://users.atw.hu/csharpkodok/?feed=rss2&amp;p=137</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Többszörös interface öröklés</title>
		<link>http://users.atw.hu/csharpkodok/?p=135</link>
		<comments>http://users.atw.hu/csharpkodok/?p=135#comments</comments>
		<pubDate>Wed, 05 Aug 2009 19:33:58 +0000</pubDate>
		<dc:creator>nameless</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://users.atw.hu/csharpkodok/?p=135</guid>
		<description><![CDATA[Töbszörös öröklés interfészekkel:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
&#160;
namespace MIInterfaceHierarchy
{
    #region interface-k
    //az interfészek többszöri öröklése működik
    public interface IDrawable
    {
        void Draw();
    }
&#160;
    public interface Iprintable
    {
  [...]]]></description>
			<content:encoded><![CDATA[<p>Töbszörös öröklés interfészekkel:</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
&nbsp;
namespace MIInterfaceHierarchy
{
    #region interface-k
    //az interfészek többszöri öröklése működik
    public interface IDrawable
    {
        void Draw();
    }
&nbsp;
    public interface Iprintable
    {
        void Print();
        void Draw(); // &lt;-- Lehetséges névtükrözés
    }
&nbsp;
    //Többszörös öröklés interészekkel
    public interface IShape : IDrawable, Iprintable
    {
        int GetNumberOfSides();
    }
    #endregion
&nbsp;
    #region megvalosito osztalyok
    class Rectangle : IShape
    {
        public int GetNumberOfSides()
        { return 4; }
&nbsp;
        public void Draw()
        { Console.WriteLine(&quot;Drawing...&quot;); }
&nbsp;
        public void Print()
        { Console.WriteLine(&quot;Printing...&quot;); }
    }
&nbsp;
    class Square : IShape
    {
        void IDrawable.Draw()
        { Console.WriteLine(&quot;IDrawable Drawing...&quot;); }
&nbsp;
        void Iprintable.Draw()
        { Console.WriteLine(&quot;Iprintable Drawing...&quot;); }
&nbsp;
        public void Print()
        { Console.WriteLine(&quot;Printing...&quot;); }
&nbsp;
        public int GetNumberOfSides()
        { return 4; }
    }
    #endregion
&nbsp;
    class Program
    {
        static void Main(string[] args)
        {
            var myRectangle = new Rectangle();
            myRectangle.Draw();
            myRectangle.Print();
            Console.WriteLine(&quot;{0}\n&quot;,myRectangle.GetNumberOfSides());
&nbsp;
            Console.ReadKey();
&nbsp;
            var mySquare = new Square();
            mySquare.Print();
            Console.WriteLine(mySquare.GetNumberOfSides());
            ((IDrawable)mySquare).Draw();
            ((Iprintable)mySquare).Draw();
&nbsp;
            Console.ReadKey();
        }
    }
}</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://users.atw.hu/csharpkodok/?feed=rss2&amp;p=135</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interface névütközés</title>
		<link>http://users.atw.hu/csharpkodok/?p=133</link>
		<comments>http://users.atw.hu/csharpkodok/?p=133#comments</comments>
		<pubDate>Wed, 05 Aug 2009 19:32:44 +0000</pubDate>
		<dc:creator>nameless</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://users.atw.hu/csharpkodok/?p=133</guid>
		<description><![CDATA[Névütközés feloldása explicit interfészimplementációval:

using System;
&#160;
namespace egyformaInterfacek
{
&#160;
    #region Interfacek
    interface IAutoSebesseg
    {
        void Kiir();
    }
&#160;
    interface IMotorSebesseg
    {
        void Kiir();
    }
&#160;
 [...]]]></description>
			<content:encoded><![CDATA[<p>Névütközés feloldása explicit interfészimplementációval:</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">using System;
&nbsp;
namespace egyformaInterfacek
{
&nbsp;
    #region Interfacek
    interface IAutoSebesseg
    {
        void Kiir();
    }
&nbsp;
    interface IMotorSebesseg
    {
        void Kiir();
    }
&nbsp;
    interface IBuszSebesseg
    {
        void Kiir();
    }
&nbsp;
    interface IBicikliSebesseg
    {
        void Kiir();
    }
    #endregion
&nbsp;
    #region Interfacek megvalositasa
    class JarmuvekSebessege : IAutoSebesseg, IBicikliSebesseg, IBuszSebesseg, IMotorSebesseg
    {
        //Ez autómatikusan privát, mivel ha úgy hívnánk meg akkor nem lehetne eldönteni melyiket is akarjuk kiírni
        void IAutoSebesseg.Kiir()
        {
            Console.WriteLine(&quot;320km/h&quot;);
        }
        void IBicikliSebesseg.Kiir()
        {
            Console.WriteLine(&quot;Attol fugg ki hajtja&quot;);
        }
        void IBuszSebesseg.Kiir()
        {
            Console.WriteLine(&quot;60km/h&quot;);
        }
        void IMotorSebesseg.Kiir()
        {
            Console.WriteLine(&quot;290km/h&quot;);
        }
    }
    #endregion
&nbsp;
    class MainClass
    {
        public static void Main()
        {
            var sebesseg = new JarmuvekSebessege();
            ((IAutoSebesseg)sebesseg).Kiir();
            ((IBicikliSebesseg)sebesseg).Kiir();
            ((IBuszSebesseg)sebesseg).Kiir();
            ((IMotorSebesseg)sebesseg).Kiir();
&nbsp;
            Console.ReadKey();
        }
    }
}</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://users.atw.hu/csharpkodok/?feed=rss2&amp;p=133</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microsoft formális, prim and proper feszabadítási minta</title>
		<link>http://users.atw.hu/csharpkodok/?p=131</link>
		<comments>http://users.atw.hu/csharpkodok/?p=131#comments</comments>
		<pubDate>Sun, 02 Aug 2009 18:27:17 +0000</pubDate>
		<dc:creator>nameless</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://users.atw.hu/csharpkodok/?p=131</guid>
		<description><![CDATA[A Microsoft formális, prim and proper feszabadítási mintát definiált, amely megteremti a robusztusság, a fenntarthatóság és a teljesítmény kzöti egyensúlyt:

using System;
using System.Collections.Generic;
using System.Text;
&#160;
namespace FinalizableDisposableClass
{
  public class MyResourceWrapper : IDisposable
  {
    //annak a megállapítására használatos, hogy a Dispose() már meghívásra került-e
    private bool disposed = false;
&#160;
   [...]]]></description>
			<content:encoded><![CDATA[<p>A Microsoft formális, prim and proper feszabadítási mintát definiált, amely megteremti a robusztusság, a fenntarthatóság és a teljesítmény kzöti egyensúlyt:</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">using System;
using System.Collections.Generic;
using System.Text;
&nbsp;
namespace FinalizableDisposableClass
{
  public class MyResourceWrapper : IDisposable
  {
    //annak a megállapítására használatos, hogy a Dispose() már meghívásra került-e
    private bool disposed = false;
&nbsp;
    public void Dispose()
    {
      //segédmetódus meghívása
      //A true érték at jez, hogy az objektumfelhasználó elindította a takarítást
      CleanUp(true);
&nbsp;
      // Most szüntessük meg a véglegesítést.
      GC.SuppressFinalize(this);
    }
&nbsp;
    private void CleanUp(bool disposing)
    {
      // Bizonyosodjunk meg róla, hogy még nem dobtunk el semmit.
      if (!this.disposed)
      {
        // Ha az eldobás igaz értéket eredményez, akkor dobjuk el az összes felügyelt erőforrást
        if (disposing)
        {
            // felügyelt erőforrás eldobása
        }
        // Itt kitakarítjuk a nem felügyelt erőforrásokat
      }
      disposed = true;
    }
&nbsp;
    ~MyResourceWrapper()
    {
      Console.Beep();
      // A segédmetódusunk meghívása
      // A false érték azt jelzi, hogy a GC eindította a takarítást
      CleanUp(false);
    }
  }
&nbsp;
  class Program
  {
    static void Main(string[] args)
    {
      Console.WriteLine(&quot;***** Dispose() / Destructor Combo Platter *****&quot;);
&nbsp;
      // A Dispose() manuális meghívása, ez nem hívja meg a véglegesítőt.
      MyResourceWrapper rw = new MyResourceWrapper();
      rw.Dispose();
&nbsp;
      // Ez nem a Dispose() metódust hívja meg, hanem elindítja a véglegesítőt és sípolást
      MyResourceWrapper rw2 = new MyResourceWrapper();
    }
  }
}</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://users.atw.hu/csharpkodok/?feed=rss2&amp;p=131</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Formalizát &amp;&amp; eldobható objektumok</title>
		<link>http://users.atw.hu/csharpkodok/?p=129</link>
		<comments>http://users.atw.hu/csharpkodok/?p=129#comments</comments>
		<pubDate>Sun, 02 Aug 2009 18:26:14 +0000</pubDate>
		<dc:creator>nameless</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://users.atw.hu/csharpkodok/?p=129</guid>
		<description><![CDATA[

     public class MyResourceWrapper : IDisposable
    {
        //a szemétgyűjtő meghívja ezt a metódus, ha az objektumot használó elfelejti
        ~MyResourceWrapper()
        {
        [...]]]></description>
			<content:encoded><![CDATA[<p><span id="more-129"></span></p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">     public class MyResourceWrapper : IDisposable
    {
        //a szemétgyűjtő meghívja ezt a metódus, ha az objektumot használó elfelejti
        ~MyResourceWrapper()
        {
            // Kitakarít bármilyen belső nem ügyelt erőforrást
            //Ne hívjuk meg a Dispose() metódust felügyelt objektumokra
        }
&nbsp;
        //Az objektum felhasználója azért hívja meg a metódust,hogy azonna kitakarítsa az erőforrásokat
        public void Dispose()
        {
            //itt kitakarítja a nem felügyelt erőforrásokat. Meghívja a Dispose()metódust
            //más tartalmazott eldobható objektumok
&nbsp;
            //Nem kell véglegesíteni, ha a felhasználó meghíva a metódust, úgyhogy szüntessük meg a véglegesítést.
            GC.SuppressFinalize(this);
        }
     }</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://users.atw.hu/csharpkodok/?feed=rss2&amp;p=129</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eldobható objektumok</title>
		<link>http://users.atw.hu/csharpkodok/?p=127</link>
		<comments>http://users.atw.hu/csharpkodok/?p=127#comments</comments>
		<pubDate>Sun, 02 Aug 2009 18:25:06 +0000</pubDate>
		<dc:creator>nameless</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://users.atw.hu/csharpkodok/?p=127</guid>
		<description><![CDATA[Ahhoz hogy eldobható objektumot hozzunk létre meg kell valósítanunk az IDisposable interfészt, melynek egyedüli tagja a Dispose()

public interface IDisposable
{
     void Dispose();
}
&#160;
egy összetetteb példa:
&#160;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
&#160;
namespace SimpleDispose
{
    public interface IDisposable
    {
        void Dispose();
    }
&#160;
 [...]]]></description>
			<content:encoded><![CDATA[<p>Ahhoz hogy eldobható objektumot hozzunk létre meg kell valósítanunk az IDisposable interfészt, melynek egyedüli tagja a Dispose()</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">public interface IDisposable
{
     void Dispose();
}
&nbsp;
egy összetetteb példa:
&nbsp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
&nbsp;
namespace SimpleDispose
{
    public interface IDisposable
    {
        void Dispose();
    }
&nbsp;
    public class MyResourceWrapper : IDisposable
    {
        //az objektum használójának meg kell hívni ezt a metódust, ha befejezte az objektum használatát
        public void Dispose()
        {
            //nem felügyelt erőforrások kitakarítása
&nbsp;
            //más tartalmazott eldobható objektumok eldobása...
&nbsp;
            Console.WriteLine(&quot;In dospose!&quot;);
        }
    }
&nbsp;
    class Program
    {
        static void Main(string[] args)
        {
            var myDispos = new MyResourceWrapper();
            myDispos.Dispose();
&nbsp;
            Console.ReadKey();
        }
    }
}</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://users.atw.hu/csharpkodok/?feed=rss2&amp;p=127</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
