Click here to Skip to main content
15,917,059 members
Home / Discussions / C#
   

C#

 
AnswerRe: GetThreadPreferredUILanguages Pin
Luc Pattyn14-Sep-11 1:52
sitebuilderLuc Pattyn14-Sep-11 1:52 
AnswerRe: GetThreadPreferredUILanguages Pin
BobJanova14-Sep-11 2:14
BobJanova14-Sep-11 2:14 
QuestionWhere to use Try/Catch block? [modified] Pin
Adam_Dev13-Sep-11 22:21
Adam_Dev13-Sep-11 22:21 
AnswerRe: Where to use Try/Catch block? Pin
BobJanova13-Sep-11 22:40
BobJanova13-Sep-11 22:40 
GeneralRe: Where to use Try/Catch block? [modified] Pin
Adam_Dev13-Sep-11 23:01
Adam_Dev13-Sep-11 23:01 
GeneralRe: Where to use Try/Catch block? Pin
BobJanova14-Sep-11 2:09
BobJanova14-Sep-11 2:09 
AnswerRe: Where to use Try/Catch block? Pin
Pete O'Hanlon13-Sep-11 22:57
mvePete O'Hanlon13-Sep-11 22:57 
GeneralRe: Where to use Try/Catch block? [modified] Pin
Adam_Dev13-Sep-11 23:10
Adam_Dev13-Sep-11 23:10 
Thanks Pete.

Would my above post be any better? Or closer to better coding?

I'm just confused really, I think I've read too many articles on exceptions (or maybe not enough infact!). Some have said to deal with exceptions in the method that was called, others have said to let exceptions propagate to the top calling method.

(Or an alternative to the GetUser() function?)

C#
// MyClass
public bool GetAdmin(string Username, string Role)
{
    try
    {   
        if (String.IsNullOrWhiteSpace(UserName) || String.IsNullOrWhiteSpace(Role))
        {
            LogEntry.New("Username/Role cannot be empty or null");
            return false;
        }

        using(MyClassAdapter myClassAdapter = new MyClassAdapter())
        {
            myClassAdapter.GetAdmin(Username, Role); 
        }
        return true;
    }
    catch(Exception ex)
    {
        //log the error
    }
 
    return false;
}


modified on Wednesday, September 14, 2011 5:27 AM

GeneralRe: Where to use Try/Catch block? Pin
Pete O'Hanlon13-Sep-11 23:50
mvePete O'Hanlon13-Sep-11 23:50 
GeneralRe: Where to use Try/Catch block? Pin
Adam_Dev14-Sep-11 0:26
Adam_Dev14-Sep-11 0:26 
AnswerRe: Where to use Try/Catch block? Pin
Luc Pattyn14-Sep-11 2:11
sitebuilderLuc Pattyn14-Sep-11 2:11 
GeneralRe: Where to use Try/Catch block? Pin
BobJanova14-Sep-11 2:22
BobJanova14-Sep-11 2:22 
GeneralRe: Where to use Try/Catch block? Pin
Adam_Dev14-Sep-11 2:33
Adam_Dev14-Sep-11 2:33 
AnswerRe: Where to use Try/Catch block? Pin
Luc Pattyn14-Sep-11 2:51
sitebuilderLuc Pattyn14-Sep-11 2:51 
JokeArrayList Pin
Subodh Kumar Jain13-Sep-11 20:38
Subodh Kumar Jain13-Sep-11 20:38 
GeneralRe: ArrayList Pin
Wayne Gaylard13-Sep-11 21:04
professionalWayne Gaylard13-Sep-11 21:04 
GeneralRe: ArrayList Pin
PIEBALDconsult14-Sep-11 2:27
mvePIEBALDconsult14-Sep-11 2:27 
GeneralRe: ArrayList Pin
Pete O'Hanlon14-Sep-11 3:51
mvePete O'Hanlon14-Sep-11 3:51 
QuestionError in Custom IIS MMC SnapIn Page ...... Pin
Shazz_Shivang200413-Sep-11 20:23
Shazz_Shivang200413-Sep-11 20:23 
QuestionWho to write HTML code using Csharp Pin
amit_ghosh1813-Sep-11 8:20
amit_ghosh1813-Sep-11 8:20 
AnswerRe: Who to write HTML code using Csharp PinPopular
Eddy Vluggen13-Sep-11 8:33
professionalEddy Vluggen13-Sep-11 8:33 
AnswerRe: Who to write HTML code using Csharp Pin
Matt Meyer13-Sep-11 8:44
Matt Meyer13-Sep-11 8:44 
AnswerRe: Who to write HTML code using Csharp Pin
Ian Shlasko13-Sep-11 8:52
Ian Shlasko13-Sep-11 8:52 
AnswerRe: Who to write HTML code using Csharp Pin
PIEBALDconsult13-Sep-11 10:30
mvePIEBALDconsult13-Sep-11 10:30 
AnswerRe: Who to write HTML code using Csharp Pin
BobJanova13-Sep-11 22:49
BobJanova13-Sep-11 22:49 

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.