Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
No Overload takes 5 arguments
Message
De
19/09/2013 09:15:17
 
 
À
19/09/2013 09:06:56
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 4.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01583574
Message ID:
01583602
Vues:
36
I broke the code down to a very simple case:
        public void SendEmails(Guid emailPK, string subject, string html, out int errorCode, out string errorMessage)
        {
            errorCode = 0;
            errorMessage = "";
        }
and now my calling code compiles properly:
                int errorCode;
                string errorMessage;
                emailNotifications.SendEmails(emailPK, email.blk_subject, email.blk_html, out errorCode, out errorMessage);
so it looks like the problem is somewhere in the code that I cut out of the SendEmails method.

Do you have any recommended reading on how to handle the throwing of an error?


>Throwing an error gets rid of the out parameters. Having them there and having to check their values on return means you expect an error. Removing them improves the design, usability, extensibility, and maintainability.
>
>But, I think you need to assign a value to the variables before calling the method.
>
>>This is during the compile. I can't run this until I fix the error in the code. FWIW I've switched to using a KeyValuePair and that is working, but I'd still love to know what I'm doing wrong.
>>
>>>Throw an exception when there's an error. Returning an error code is very C/C++ like and is discouraged in .Net.
>>>
>>>
>>>>Hi,
>>>>
>>>>I'm trying to adjust a method so I can get two bits of information out of it. Previously I was just returning an error code, now I would like to return an error message along with the code. I found one way to do this is to use out parameters, so I adjusted my methods definition to this:
>>>>
>>>>
public void SendEmails(Guid emailPK, string subject, string html, out int errorCode, out string errorMessage)
>>>>
>>>>When I try calling this method like this:
>>>>
>>>>
int errorCode;
>>>>string errorMessage;
>>>>emailNotifications.SendEmails(emailPK, email.blk_subject, email.blk_html, out errorCode, out errorMessage);
>>>>
>>>>I get this error:
>>>>
>>>>"No overload for method 'SendEmails' takes 5 arguments"
>>>>
>>>>Maybe it's too early in th emorning for me but I think I'm counting correctly.
>>>>
>>>>Can anybody help enlighten me, please?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform