response = myProvider.ProcessMessage(myMessage.ToString());
If I try to type
response = myProvider.ProcessMessage(myMessage);
I get a build error stating that it cannot implicitly convert type 'SomeCoolMessage' to 'string.' So, what if I want to implicitly convert between the two? In the SomeCoolMessage class I add a new operator
public static implicit operator string(SomeCoolMessage m)
{
return m.ToString();
}
Now I can write
response = myProvider.ProcessMessage(myMessage);
and everything just works.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.