What's new in C# 11

 The following features were added in C# 11:

    1. Raw string literals
    2. Generic math support
    3. Generic attributes
    4. UTF-8 string literals
    5. Newlines in string interpolation expressions
    6. List patterns
    7. File-local types
    8. Required members
    9. Auto-default structs
    10. Pattern match Span<char> on a constant string
    11. Extended nameof scope
    12. Numeric IntPtr
    13. ref fields and scoped ref
    14. Improved method group conversion to delegate
    15. Warning wave 7 

Generic Attributes:

// Before C# 11: Old feature

public class TypeAttribute : Attribute


   public TypeAttribute(Type t) => ParamType = t;

   public Type ParamType { get; }



And to apply the attribute, you use the typeof operator:


public string Method() => default;


// C# 11 feature: New feature

public class GenericAttribute<T> : Attribute { }


Then, specify the type parameter to use the attribute:


public string Method() => default;


Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..

My Tech Blog - https://www.code-sample.com/
My Books - Book 1 and Book 2

www.code-sample.com/. Powered by Blogger.