Click here to Skip to main content
15,914,447 members
Home / Discussions / C#
   

C#

 
AnswerRe: Flickering problem! help! :( Pin
janita1-Aug-06 15:41
janita1-Aug-06 15:41 
Questionconnection for excel Pin
Mohammed Elkholy30-Jul-06 11:35
Mohammed Elkholy30-Jul-06 11:35 
AnswerRe: connection for excel Pin
Guffa30-Jul-06 11:53
Guffa30-Jul-06 11:53 
Questionnew process information ? Pin
raol duke30-Jul-06 9:47
raol duke30-Jul-06 9:47 
QuestionIs there any packer for .NET? Pin
xkx3230-Jul-06 7:13
xkx3230-Jul-06 7:13 
AnswerRe: Is there any packer for .NET? Pin
leppie30-Jul-06 15:31
leppie30-Jul-06 15:31 
QuestionShould I use Dispose in this situation Pin
xkx3230-Jul-06 7:01
xkx3230-Jul-06 7:01 
AnswerRe: Should I use Dispose in this situation Pin
Colin Angus Mackay30-Jul-06 11:14
Colin Angus Mackay30-Jul-06 11:14 
xkx32 wrote:
i'm wondering if the last line: ins.Dispose(); is necessary? Or C# does it automaticlly?...


To the first question - If the class has a Dispose() method then, yes, you should use it.

To the second question - If the class has a destructor (Finalizer) that calls Dispose() then, yes, it will eventually get to it. BUT, just because it will get to it eventually doesn't mean you can get all lazy about it. If a class supports Dispose() it is usually for a very good reason and its very existance suggests that you should use it.


xkx32 wrote:
i mean disposing the object as soon as the method is finish


If that is where the object is naturally no longer required then that is where you should dispose of it. If you are only going to use an object within one method and it won't be stored anywhere else by the time the method completed then you may like to use the following instead
using (MyClass ins = new MyClass())
{
    ins.AMethod();
}
What happens here is that as soon as the code exits the scope of the using block for what ever reason (it might reach it naturally, or it might be in the process of throwing an exception) the object will be Disposed of.


AnswerRe: Should I use Dispose in this situation Pin
Guffa30-Jul-06 11:51
Guffa30-Jul-06 11:51 
AnswerRe: Should I use Dispose in this situation Pin
LongRange.Shooter31-Jul-06 5:59
LongRange.Shooter31-Jul-06 5:59 
QuestionHow to get Text control value into a numeric data type? Pin
Amol Ravatale30-Jul-06 5:39
Amol Ravatale30-Jul-06 5:39 
AnswerRe: How to get Text control value into a numeric data type? [modified] Pin
Shy Agam30-Jul-06 5:53
Shy Agam30-Jul-06 5:53 
AnswerRe: How to get Text control value into a numeric data type? Pin
User 665830-Jul-06 6:15
User 665830-Jul-06 6:15 
GeneralRe: How to get Text control value into a numeric data type? [modified] Pin
Shy Agam30-Jul-06 6:44
Shy Agam30-Jul-06 6:44 
GeneralRe: How to get Text control value into a numeric data type? Pin
User 665830-Jul-06 8:27
User 665830-Jul-06 8:27 
GeneralMy dear friends.... Thanks both of you Pin
Amol Ravatale30-Jul-06 21:14
Amol Ravatale30-Jul-06 21:14 
QuestionHow to generate combo box in a datagrid in windows forms( .Net 1.1) Pin
Rocky#30-Jul-06 0:52
Rocky#30-Jul-06 0:52 
QuestionPLEASE HELP !!!!!!!!!! Pin
RoyiNamir30-Jul-06 0:12
RoyiNamir30-Jul-06 0:12 
AnswerRe: PLEASE HELP !!!!!!!!!! Pin
Christian Graus30-Jul-06 11:59
protectorChristian Graus30-Jul-06 11:59 
AnswerRe: PLEASE HELP !!!!!!!!!! Pin
Rob Graham30-Jul-06 15:57
Rob Graham30-Jul-06 15:57 
QuestionStack overflow in System.Drawing.dll... Pin
Shy Agam29-Jul-06 22:50
Shy Agam29-Jul-06 22:50 
AnswerRe: Stack overflow in System.Drawing.dll... Pin
mav.northwind30-Jul-06 3:23
mav.northwind30-Jul-06 3:23 
GeneralRe: Stack overflow in System.Drawing.dll... Pin
Shy Agam30-Jul-06 5:09
Shy Agam30-Jul-06 5:09 
GeneralRe: Stack overflow in System.Drawing.dll... Pin
leppie30-Jul-06 5:33
leppie30-Jul-06 5:33 
GeneralRe: Stack overflow in System.Drawing.dll... Pin
Shy Agam30-Jul-06 5:48
Shy Agam30-Jul-06 5:48 

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.