I studied the code that comes with the C# DX SDK and noticed that in
\Samples\C#\Direct3D\Tutorials\Tutorial6\meshes.cs the Main-method looks like this:
static void Main()
{
using (Meshes frm = new Meshes())
{
if (!frm.InitializeGraphics()) // Initialize Direct3D
{
MessageBox.Show("Could not initialize Direct3D. This tutorial will exit.");
return;
}
frm.Show();
// While the form is still valid, render and process messages
while(frm.Created)
{
frm.Render();
Application.DoEvents();
}
}
}
I wondered why they used a using directive (line 3) so I changed the code to
static void Main()
{
Meshes frm = new Meshes()
{
if (!frm.InitializeGraphics()) // Initialize Direct3D
{
...
and it still compiled and ran! This sample isn't the only one they uses the using directive, but the question is why do they use it? I did a quick search on MSDN but didn't find anyting. Can anyone please explain?
[edited by - Enselic on April 20, 2004 9:03:28 AM]