Click here to Skip to main content
15,913,219 members
Home / Discussions / C#
   

C#

 
GeneralRe: combobox in datagrid Pin
Christian Graus15-Apr-08 0:50
protectorChristian Graus15-Apr-08 0:50 
GeneralRe: combobox in datagrid Pin
sarilee15-Apr-08 1:15
sarilee15-Apr-08 1:15 
Generaltemplates in datagrid Pin
sarilee14-Apr-08 23:45
sarilee14-Apr-08 23:45 
GeneralRe: templates in datagrid Pin
Christian Graus14-Apr-08 23:53
protectorChristian Graus14-Apr-08 23:53 
GeneralStreamWriter Pin
George_George14-Apr-08 23:44
George_George14-Apr-08 23:44 
GeneralRe: StreamWriter Pin
N a v a n e e t h15-Apr-08 0:25
N a v a n e e t h15-Apr-08 0:25 
GeneralRe: StreamWriter Pin
George_George15-Apr-08 2:55
George_George15-Apr-08 2:55 
GeneralRe: StreamWriter Pin
N a v a n e e t h15-Apr-08 20:36
N a v a n e e t h15-Apr-08 20:36 
George_George wrote:
what is the relationship between Finalize method and destructor?


As far as the CLR is concerned, in C# something looks like a destructor is finalize method. System.Object has a Finalize() method, but C# won't allow you to override this. In C#, destructor is called as finalize method. To make it more clear look at the below class which uses a destructor and check the IL generated code
class Program
{
    static void Main(string[] args)
    {
    }
    ~Program()
     {
        // clean resources
     }
}

//IL CODE

.class private auto ansi beforefieldinit Program
        extends [mscorlib]System.Object
    {
        .method public hidebysig specialname rtspecialname instance void .ctor() cil managed
        {
        }

        .method family hidebysig virtual instance void Finalize() cil managed
        {
        }

        .method private hidebysig static void Main(string[] args) cil managed
        {
            .entrypoint
        }

    }
In the IL code you can see the Finalize() method. So C# compiler converted destructor to this Finalize() method. This will be called by garbage collector.

Considering performance, implementing destructor is costly. GC will maintain a separate queue for items that need finalization. So you should implement the Dispose() pattern and clean all your resources. Also call GC.SuppressFinalize() from dispose which will suppress the finalization.

Hope things are clear now

All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia

How to use google | Ask smart questions

GeneralRe: StreamWriter Pin
George_George16-Apr-08 0:05
George_George16-Apr-08 0:05 
GeneralRe: StreamWriter Pin
N a v a n e e t h16-Apr-08 2:00
N a v a n e e t h16-Apr-08 2:00 
GeneralRe: StreamWriter Pin
George_George16-Apr-08 2:22
George_George16-Apr-08 2:22 
GeneralRe: StreamWriter Pin
N a v a n e e t h16-Apr-08 3:01
N a v a n e e t h16-Apr-08 3:01 
GeneralRe: StreamWriter Pin
George_George16-Apr-08 3:42
George_George16-Apr-08 3:42 
GeneralRe: StreamWriter Pin
Gareth H15-Apr-08 0:26
Gareth H15-Apr-08 0:26 
GeneralRe: StreamWriter Pin
George_George15-Apr-08 2:54
George_George15-Apr-08 2:54 
QuestionHow I can paly Video files with C# & DirextX? Pin
Mohammad Dayyan14-Apr-08 23:43
Mohammad Dayyan14-Apr-08 23:43 
GeneralRe: How I can paly Video files with C# & DirextX? Pin
Christian Graus14-Apr-08 23:54
protectorChristian Graus14-Apr-08 23:54 
GeneralRe: How I can paly Video files with C# & DirextX? Pin
Mohammad Dayyan15-Apr-08 10:36
Mohammad Dayyan15-Apr-08 10:36 
Generalinteger type in C# Pin
George_George14-Apr-08 23:33
George_George14-Apr-08 23:33 
GeneralRe: integer type in C# Pin
N a v a n e e t h15-Apr-08 0:32
N a v a n e e t h15-Apr-08 0:32 
GeneralRe: integer type in C# Pin
George_George15-Apr-08 2:56
George_George15-Apr-08 2:56 
GeneralRe: integer type in C# Pin
Gareth H15-Apr-08 0:34
Gareth H15-Apr-08 0:34 
GeneralRe: integer type in C# Pin
George_George15-Apr-08 2:56
George_George15-Apr-08 2:56 
GeneralRe: integer type in C# Pin
leppie15-Apr-08 4:28
leppie15-Apr-08 4:28 
GeneralRe: integer type in C# Pin
George_George15-Apr-08 4:30
George_George15-Apr-08 4:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.