type used in a using statement must be implicitly convertible to 'System.IDisposable'
Error in itself is self explanatory.
The
using
Statement is intended to be used to ensure the disposal of an object at the end of the using block, thus, only types which are disposable may be used in such a statement.
Details here:
Compiler Error CS1674 [
^]
You need to do implement
IDisposable
interface for your
UserProfile
class, something like:
class D : IDisposable {
void IDisposable.Dispose() {}
public void Dispose() {}
public static void Main() {
using (D d = new D()) {}
}
}