Languages

C# - Error CS1674 "ILogger": The type used in the using statement must be implicitly convertible to the interface "System.IDisposable"

0 points
Asked by:
Gigachad2137
1000

CommonLogger.cs file:

 

Program.cs file: 

ILogger.cs file: 

IDisposable.cs file:

 

The question was modified by moderator to make it more readable.

 

1 answer
1 points
Answered by:
Root-ssh
178260

Looking on the question title I think you have problem with using statement and IDisposable interface.

C# by default provides IDisposable interface that can be used to release some resources (unmanaged resources). Classes that implement IDisposable intereface may be used with using statement that releases resouces automatically when the using statement execution is ended.

But your CommonLogger class implements your own IDisposable interface that you want to use later in using (ILogger logger = new CommonLogger(loggers)). The solution for the Error CS1674 is to remove your IDisposable interface and use the one provided by .NET.

 

References

  1. IDisposable Interface - Microsoft Docs

  2. using statement - Microsoft Docs

0 commentsAdd comment
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join