- Home /
Question by
commodore · Dec 24, 2014 at 08:27 AM ·
c#javascriptimportusing
What is the equivalent of using in javascript?
What would this look like in javascript? Is it the same same as import?
using (MemoryStream byteStream = new MemoryStream())
{
using (BinaryWriter stream = new BinaryWriter(byteStream))
{
// stuff
}
}
Comment
Answer by Paulius-Liekis · Dec 24, 2014 at 12:50 PM
No, in this case using is not the same as import. It's RAII statement, i.e. at the end of using section the resources are released.
You probably can rewrite it without using (if we ignore exception safety; in C#):
MemoryStream byteStream = new MemoryStream();
BinaryWriter stream = new BinaryWriter(byteStream);
stream.Close();
byteStream.Close();
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Different language scripts - how to avoid trouble? 1 Answer
Distribute terrain in zones 3 Answers
Help converting C# to Javascript? 0 Answers
Making a script's functions available with 'using...' 1 Answer