Click here to Skip to main content
15,888,610 members
Home / Discussions / C#
   

C#

 
AnswerRe: Paging in datagridview Pin
dan!sh 5-Jul-09 22:17
professional dan!sh 5-Jul-09 22:17 
QuestionBest approach to use try catch finally Pin
Pankaj Saha5-Jul-09 21:03
Pankaj Saha5-Jul-09 21:03 
AnswerRe: Best approach to use try catch finally Pin
dan!sh 5-Jul-09 21:12
professional dan!sh 5-Jul-09 21:12 
GeneralRe: Best approach to use try catch finally Pin
Pankaj Saha5-Jul-09 21:36
Pankaj Saha5-Jul-09 21:36 
AnswerRe: Best approach to use try catch finally Pin
Alan N5-Jul-09 21:43
Alan N5-Jul-09 21:43 
AnswerRe: Best approach to use try catch finally Pin
Pete O'Hanlon5-Jul-09 22:06
mvePete O'Hanlon5-Jul-09 22:06 
GeneralRe: Best approach to use try catch finally Pin
Pankaj Saha5-Jul-09 22:38
Pankaj Saha5-Jul-09 22:38 
GeneralRe: Best approach to use try catch finally Pin
Pete O'Hanlon5-Jul-09 23:19
mvePete O'Hanlon5-Jul-09 23:19 
Pankaj Saha wrote:
Can I write the above code without try catch finally block and it will close the reader if any error is generated during the process ?


If you mean, can you dispense with try/finally as well, then you should not. The finally portion will close the reader, regardless as to whether or not an exception is thrown. As StreamReader is a disposable object though, you could always rewrite this with:
using(StreamReader sr = new StreamReader(fileName, Encoding.UTF8))
{
  // Do the file stuff.
}
When StreamReader is disposed the stream is closed (if it is open).

"WPF has many lovers. It's a veritable porn star!" - Josh Smith

As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.


My blog | My articles | MoXAML PowerToys | Onyx



AnswerRe: Best approach to use try catch finally Pin
Luc Pattyn6-Jul-09 0:23
sitebuilderLuc Pattyn6-Jul-09 0:23 
GeneralRe: Best approach to use try catch finally Pin
PIEBALDconsult6-Jul-09 4:31
mvePIEBALDconsult6-Jul-09 4:31 
GeneralRe: Best approach to use try catch finally Pin
Luc Pattyn6-Jul-09 5:23
sitebuilderLuc Pattyn6-Jul-09 5:23 
QuestionError after selecting text in richtextbox Pin
Khawar Abbas15-Jul-09 20:50
Khawar Abbas15-Jul-09 20:50 
AnswerRe: Error after selecting text in richtextbox Pin
Alan N5-Jul-09 21:49
Alan N5-Jul-09 21:49 
AnswerRe: Error after selecting text in richtextbox Pin
Luc Pattyn6-Jul-09 0:26
sitebuilderLuc Pattyn6-Jul-09 0:26 
QuestionReport Viewer Control - Pin
devvvy5-Jul-09 20:25
devvvy5-Jul-09 20:25 
Questionhow to get only time from datetime? Pin
swetha_insoft5-Jul-09 20:22
swetha_insoft5-Jul-09 20:22 
AnswerRe: how to get only time from datetime? Pin
SeMartens5-Jul-09 20:26
SeMartens5-Jul-09 20:26 
AnswerRe: how to get only time from datetime? Pin
Anubhava Dimri5-Jul-09 20:41
Anubhava Dimri5-Jul-09 20:41 
AnswerRe: how to get only time from datetime? Pin
himanshu25615-Jul-09 20:44
himanshu25615-Jul-09 20:44 
AnswerRe: how to get only time from datetime? Pin
stancrm5-Jul-09 20:56
stancrm5-Jul-09 20:56 
Questionhow to write in excel cells using DataReader if a particular cell is “ReadOnly” using C# Pin
Krishna Aditya5-Jul-09 20:20
Krishna Aditya5-Jul-09 20:20 
AnswerRe: how to write in excel cells using DataReader if a particular cell is “ReadOnly” using C# Pin
dan!sh 5-Jul-09 20:51
professional dan!sh 5-Jul-09 20:51 
GeneralRe: how to write in excel cells using DataReader if a particular cell is “ReadOnly” using C# Pin
Krishna Aditya5-Jul-09 20:57
Krishna Aditya5-Jul-09 20:57 
GeneralRe: how to write in excel cells using DataReader if a particular cell is “ReadOnly” using C# Pin
dan!sh 5-Jul-09 21:10
professional dan!sh 5-Jul-09 21:10 
QuestionC# + MS ACCESS application - daily report problems Pin
daydr3am3r5-Jul-09 19:34
daydr3am3r5-Jul-09 19:34 

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.