using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BasicGramms
{
	public delegate string ConcatMsg(string str, int num);
	public delegate void DelegateMethod();
	public delegate void DelegateCallback(string str);
	public delegate int DelegateMultiply(int x, int y);
	internal class BasicDelegate
	{
		public void DoTest()
		{
			ConcatMsg concatMsg = new ConcatMsg(Msg);

			Console.WriteLine(concatMsg("Huffman", 45));

			DelegateMethod delegateMethod = Msg1;
			delegateMethod += Msg2;
			delegateMethod += Msg3;
			delegateMethod -= Msg2;
			delegateMethod();

			DelegateCallback callback = Msg_Callback;
			SumMethod(1, 6, callback);

			DelegateMultiply delegateMultiply = delegate (int x, int y)
			{
				return x * y;
			};
			Console.WriteLine(delegateMultiply(5, 7));
		}

		public string Msg(string str, int num)
		{
			return $"Name: {str}, Age: {num}";
		}

		public void Msg1()
		{
			Console.WriteLine("1");
		}

		public void Msg2()
		{
			Console.WriteLine("2");
		}

		public void Msg3()
		{
			Console.WriteLine("3");
		}

		public void Msg_Callback(string str)
		{
			Console.WriteLine(str);
		}

		public void SumMethod(int x, int y, DelegateCallback callback)
		{
			int sum = x + y;
			callback($"Result: {sum}");
		}
	}
}
