Relax new()
and required
mutual exclusion
#7947
Unanswered
TonyValenti
asked this question in
Language Ideas
Replies: 1 comment 7 replies
-
This cannot work because the compiler does not know that public static void Test<T> where T : LegacyRecord, new() sets_required_properties // new keyword here
{
var ret = new T() { Id = 0, }; // no error
var x = new T(); // error - Id not set
return ret;
} The imaginary new |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Today when a type has a
required
property, the type cannot fulfill thenew()
constraint.This requirements should be removed when all the following are true:
Example:
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions