Compiler Error CS1728
Cannot bind delegate to 'member' because it is a member of 'type'
You cannot bind delegates to members of Nullable
value types.
Example
The following sample generates CS1728:
// CS1728.cs
class Test
{
delegate T GetT<T>();
delegate T GetT1<T>(T t);
delegate bool E(object o);
delegate int I();
delegate string S();
static void Main()
{
int? x = null;
int? y = 5;
GetT<int> d1 = x.GetValueOrDefault; // CS1728
GetT<int> d2 = y.GetValueOrDefault; // CS1728
GetT1<int> d3 = x.GetValueOrDefault; // CS1728
GetT1<int> d4 = y.GetValueOrDefault; // CS1728
}
}
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.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for