Skip to content

How to override delete operator in JS from C#. #1426

Answered by lahma
nathan130200 asked this question in Q&A
Discussion options

You must be logged in to vote

I think that would be a bit leaky abstraction, delete and and Dispose pattern don't map that well together. The explicit resource management proposal would be something that would naturally map to .NET side.

Maybe you could have a helper function that wraps try-finally and Dispose following the actual semantics that .NET CLR/compiler does, something like:

function usingDisposable(target, action) {
  try {
    action(target);
  }
  finally {
	target.dispose();
 }
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by nathan130200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants