   Direct3D device question
  Hello all, I am relatively new to programming in managed directX, and need some help. I am working on a small project for my first year, and I came across something while looking around at different engine codes. My question is this: I have created a device object for my engine. To render the different model and buffer classes, I use  a render function which takes the engine device as a parameter. The render is then done using the parameter device. However in the other engines I noticed that each mesh or buffer class has a private Direct3d device attribute. Which is created in the constructor using the engine device. Constructor ( Device engineDevice ){attributeDevice = engineDevice ;}i.e. When their render function is called, they do not take a device parameter; instead they use the attribute.I don't understand two things:1. What happens if the engine device is lost or reset? Will I have to create new Device event handlers for each class?2. Is it not costly to make several devices, and not just use one like I have been doing?Thanks for any help folks :)   
  Even in the example you just demonstrated, where the Direct3D Device is passed as a parameter to the model classes, there is only one device created, but multiple pointers pointing to it. I would recommend that before you continue to work with Direct3D, which is not that easy, that you get a good book about C# and know it well. We all have to start somewhere, but don't go too fast! :)   ;  lol, thanks David. I actually am jumping a ahead of my time, which I realize. I have done quite a bit of studying but I guess I never realized this. Maybe you could help me understand this hypothetical:int x = 1;int y = x;So both x and Y are now 1.x++;Now x is 2 and y is 1. Why is this? Why is the y variable not pointing to the x's memory cell? Yet when I do it with classes like so:TestClass x = new TestClass();TestClass y;x.number = 1;y = x;x.number++;Now the class y is pointing to the class x and both of their individual attributes are the same. Why is this? Sorry if this is a reeeeeally nooby question - but I guess I never thought to ask it :P   ;  Device is a reference type (in C#, all classes are reference types); therefore, when it is passed in a function call, it is effectively passed by reference (a new Device object is not created). So overall there is only 1 Device, but multiple references to it.As suggested, if you don't understand C# well, you might want to get a good book and get a solid understanding of C# before going further into Direct3D.Hope this helps :)   ;  Thanks guys. I actually have done quite a bit of work with dircectX now. I guess I never thought to check this silly question. Anyways thanks a heap :)   ;  ok, just to clarify a bit...The primitive types (int, float, double, etc.) and structs are all value types in C#. In this case, an object is copied during assignment, passing via function calls, etc.Classes (as well as the string and object types) are reference types. In this case, a reference to an object (if you know C++, you can think of it as a pointer), not the object itself, is made/copied during assignment, passing via function calls, etc.;  As directrix has pointed out, they are two types of variables in C#: value and reference types. Here are two links from MSDN which will help you understand the differences:Value TypesReference TypesYou might want to have a look at a language like C before learning any higher-level language like C# or Java. It will take you more time, but it will give you a strong base in memory management. Even if it is done transparently in C#, knowing what is happening is often a plus.   ;  Thanks guys you have been very helpful :)   