C# what is the meaning of where T : class, new()

T.Zacks 3,991 Reputation points
2022-09-17T18:35:05.73+00:00

see 2 sample code
class DataStore<T> where T : class, new()
{
public T Data { get; set; }
}

class DataStore<T> where T : new()  
{  
    public T Data { get; set; }  
}  

what is difference between where T : new() and where T : class, new() ? thanks

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,858 questions
0 comments No comments
{count} votes

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.