Thursday, May 9, 2019

C# : How to declare Async method in Interface



We can not declare Async method in interface or it's not needed as Async is code marker for compiler it has no relation with overriding feature. If we want to declare Async methods in Interface we need to set return type of method to Task/Task also void method of interface can be implemented as Async. See below example :(Methods implemented in code are not providing any meaningful functionality,it's just to check/show use of Async from interface.)



No comments:

Post a Comment

C# Record type: Something to remember while using record types

  Record in c# provide a concise and expressive way to create immutable data types, record is a keyword in c#, we can use this keyword with ...