Possible Duplicate:
Really impossible to use return type overloading?
Is there a way to take the same method and overload its return type? Like I did in the code below. I tried this but it says there is ambiguity between the two.
//supporting methods
private AutoResetEvent ReturnData = new AutoResetEvent(false);
public void PostMessage(string msg)
{ this.Message = msg; this.ReturnData.Set(); }
private string Message;
//a return value overload
public string GetMessage()
{
this.ReturnData.WaitOne();
return this.Message;
}
public byte[] GetMessage(){
this.ReturnData.WaitOne();
return encoder.GetBytes(Message);
}
You can’t overload by return type in C#.
When something similar needs to be done in the .NET framework they usually change the method name to include the name of the return type.
Example:
BinaryReaderExample:
SQLDataReaderIn your case you could for example use
GetMessageStringandGetMessageBytes.