Finished Defining a Delegate

jason.zhu 2021-02-22 10:11:30 +00:00
parent 3b7e226312
commit ae5b27fd2f
1 changed files with 18 additions and 0 deletions

View File

@ -4,8 +4,26 @@ using Xunit;
namespace GradeBook.Tests
{
using GradeBook;
public delegate string WriteLogDelegate(string logMessage);
public class TypeTests
{
[Fact]
public void WriteLogDelegateCanPointToMethod()
{
string msg = "test";
WriteLogDelegate log = new WriteLogDelegate(ReturnMessage); // Instantiate a delegate
var result = log(msg); // Invoking a delegate
Assert.Equal(result, msg);
}
string ReturnMessage(string message)
{
return message;
}
[Fact]
public void ValueTypesAlsoPassByValue()
{