convert error?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Dear reader,

In my code I get the following error:

AddComment.cs(32): The best overloaded method match for
'WebLogger.Message.SelectMessage(string, out string, out string)' has some
invalid arguments

This is the code:


class Message
{
...
public int SelectMessage(string pID, out string pTitle, out string
pAddedDate)
{
...
}
}

class AddComment
{
...
public void InsertComment(int pMessageID, string pAuthor, string pEmail,
string pComment)
{
string msgTitle, msgAddedDate;
Message msg = new Message();
msg.SelectMessage(pMessageID, out msgTitle, out msgAddedDate);
}
}

Does anybody have an idea?
I'm quite new to C#, so this could easily be something stupid.

Thanks in advance,

Eddy de Boer
 
eddy said:
Dear reader,

In my code I get the following error:

AddComment.cs(32): The best overloaded method match for
'WebLogger.Message.SelectMessage(string, out string, out string)' has some
invalid arguments

This is the code:


class Message
{
...
public int SelectMessage(string pID, out string pTitle, out string
pAddedDate)
{
...
}
}

class AddComment
{
...
public void InsertComment(int pMessageID, string pAuthor, string pEmail,
string pComment)
{
string msgTitle, msgAddedDate;
Message msg = new Message();
msg.SelectMessage(pMessageID, out msgTitle, out msgAddedDate);
}
}

Does anybody have an idea?
I'm quite new to C#, so this could easily be something stupid.

SelectMessage requires a string as the first parameter, you are trying to
pass in int (pMessageID). You need to convert that int to a string first,
easily done by using pMessageID.ToString().
 
Hi,

InsertComment uses

int pMessageID

but SelectMessage uses

string pID

Either change SelectMessage to use int pID, or use pMessage.ToString() when calling SelectMessage
 
<=?Utf-8?B?ZWRkeSBkZSBib2Vy?= <eddy de
In my code I get the following error:

AddComment.cs(32): The best overloaded method match for
'WebLogger.Message.SelectMessage(string, out string, out string)' has some
invalid arguments

Well, pMessageID is an int, and you're trying to pass it in as a
string. What do you want to do with it? You could call ToString() on
pMessageID if you want:

msg.SelectMessage(pMessageID.ToString(),
out msgTitle,
out msgAddedDate);
 
Back
Top