0

In C# one can type the using verb in line width the code sometimes, like

using (textwriter){ ..... }

I like that writing style and am wondered what is required to allow that for my own Api's.

Peter
  • 2,043
  • 1
  • 21
  • 45
  • It's not just a fancy style of coding, it's here for the specific reason – managed resources handling. Instances of types, implementing `IDisposable` interface, should be disposed with use of `Dispose` invocation. `using` statement is a convenient way to guarantee that `Dispose` will be actually called. See this [article](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-statement) – Uladzislaŭ May 20 '18 at 10:20

1 Answers1

0

As long as your objects are IDisposable then you can use it with the using statement.

Ousmane D.
  • 54,915
  • 8
  • 91
  • 126