Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Method name expected
When creating a delegate, specify a method. For more information, see Delegates.
The following sample generates CS0149:
// CS0149.cs
using System;
delegate string MyDelegate(int i);
class MyClass
{
// class member-field of the declared delegate type
static MyDelegate dt;
public static void Main()
{
dt = new MyDelegate(17.45); // CS0149
// try the following line instead
// dt = new MyDelegate(Func2);
F(dt);
}
public static string Func2(int j)
{
Console.WriteLine(j);
return j.ToString();
}
public static void F(MyDelegate myFunc)
{
myFunc(8);
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.