Guys i need some help here, i have error in Line 50: CS0236 C# A field initializer cannot reference the non-static field, method, or property Line 51: CS0236 C# A field initializer cannot reference the non-static field, method, or property
namespace ConsoleApplication5
{
public delegate string Metodo(string t1, string t2);
class Program
{
static void Main(string[] args)
{
}
}
public class ExemploDel
{
public static string NomeMetodo(string t1, string t2)
{
return t1 + t2;
}
Metodo meuMetodo = NomeMetodo;
}
public class Metodos
{
public string Method1(string tx1, string tx2)
{
return tx1 + tx2;
}
public string Method2(string tx1, string tx2)
{
return tx2 + tx1;
}
}
public class DelegatesEx
{
public static string NomeMetodo(string t1, string t2)
{
return t1 + t2;
}
Metodos obj = new Metodos();
Metodo m1 = obj.Method1;
Metodo m2 = obj.Method2;
Metodo m3 = NomeMetodo;
}
}