Hello, I’m working on this task:
Remove implementation and all forbidden members from the interface IMessage. Move them to the class Message, so that class Message implements interface IMessage. Your program should compile.
Here is my code:
namespace Interfaces
{
public interface IMessage
{
string Type { get; }
string Payload { get; }
void Read(string payload);
}
public class Message : IMessage
{
public string Type
{
get
{
return "Encrypted message";
}
}
public string PayLoad
{
get
{
return PayLoad;
}
}
public void Read(string payload)
{
payload = PayLoad;
}
}
public class EveryoneLikesSendingMessagesNowadays
{
public static void Main()
{
var message = new Message();
message.Read("I will never implement methods and properties in an interface.");
Console.WriteLine(message.Payload);
}
}
}
Can’t get what I have to do in ‘public void Read(string payload)’ . Please, help me to understand the task and my mistakes.