Using `using`, am I understanding this right?

How does using differ between these two use-cases (haha, puns).
c#
using System;
using System.LINQ;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.EntityFrameworkCore.Sqlite;
c#
using System;
using System.LINQ;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.EntityFrameworkCore.Sqlite;
and
c#
using (var context = new Database_Load())`?
c#
using (var context = new Database_Load())`?
6 Replies
Pobiega
Pobiega11mo ago
same keyword, but used entirely differently the top one is just "importing" a namespace, so you can use types from them without fully qualifying that namespace the bottom one has to do with disposables
Never Ending Trance...
Ah ok I think I understand. So despite the same keyword usage, the importing namespace portion does not handle disposal at all? I think that is where I became confused is reading about the disposal for the second use-case and not understanding how it applied to the first.
Thinker
Thinker11mo ago
These are two completely unrelated concepts You can literally just pretend it says handledispose (var context = new Database_Load())
Pobiega
Pobiega11mo ago
yeah think of it as two different keywords
Thinker
Thinker11mo ago
Or import System;
Never Ending Trance...
Ah ok, thank you that clears it up much more. I appreciate your time and help in understanding this better!
Want results from more Discord servers?
Add your server