In non technical teams the stack is an optimized memory bank that is very fast. The heap is a memory bank that isn't as fast but great for handling objects of varying sizes. So when you create an object, .NET looks to see if it is a native or reference type. If it is a native type, the value it put on the stack, otherwise it is put on the heap.
The reason for this is that the stack only handles objects that are 32 bits in size. The fact that all memory allocations are the same size is what makes it fast. Also it's not a pointer to a value that is stored, it's the actual value itself. Because of this Boolean values actually occupy 4 bytes of memory. Native types like doubles are stored in 2 x 4 bytes
A reference type like a string for example could be any size. It could also be very large. So what happens is the string is stored on the heap and a pointer is created and put on the stack so it can be found quickly. Either way, the combination offers a lot faster solution than a simple memory model.
I read Jeffrey Richter's book on CLR but I must have totally misunderstood what I was reading. Hopefully someone will explain the difference in this topic. At the moment I'm aware I've got it wrong. I just don't know why.
I understand what you are trying to say but I didn't have another choice and I thought this is the right place to ask that problem. I already excused for my question you consider non-advanced and unprofessional . I hope you realize why.
You do realise that OG wasn't addressing you don't you? What he was saying is that the answer you were given was wrong - not that you were stupid for asking the question. It's actually a pretty fair question, as the concepts are misunderstood, which you can see from the answers.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
No, no, you misunderstood - that was not directed at you or your question (which is a good, sensible question). That is why it was a reply to RobCroll and not to you, and why his answer is light grey, and yours is still blue.
His answer to your question was wrong in just about every respect, and what he said you should ignore - look at Dave Kreskowiak's answer which is much, much better. That is why I (and I suspect others) voted him down - the advice was bad. If you look at the bottom left corner of a message you will see a "rate this message" facility. Have a look at his answer: 1.71/5 (7 votes) indicating he has had seven ratings, and that they have generally been unhappy. A vote of one is a "this is bad", a vote of 5 is a "this is good". If your message has no votes, it is blue, if it is down voted, it goes grey. If it is upvoted it goes green.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
The stack is (NOT OPTIMIZED VERY FAST MEMORY!) just an area in memory where various values are stored in a Last In, First Out fashion. It's used to hold simple variable values, pointers to objects, parameters for methods calls, return addresses for returning control back to where a method was called from, ...
A heap is a block of memory that contains both free (reserved for your app but unused) memory and allocated objects such as buffers, class instances, strings, or other complex types.
This uesd to be a lot easier question to answer - the stack was a small bit of RAM pointed to by the CPU Stack Pointer (SP) register, which made it fast and easy to access. Every CALL instruction pushed the current values in all CPU registers onto the stack, then popped them back when the CALLed routine was finished to resume execution. The Heap was a block reserved in RAM by an application to hold and access run-time data. Now it's a bit more complex, but this[^] discussion puts it in perspective.
DataTable dt = new DataTable();
SqlConnection con = new SqlConnection("Data Source=MS-TOSHIBA;Initial Catalog=dalily system;Integrated Security=True");
SqlCommand cmd = new SqlCommand("select place.name,place.address,place.telephone,place.website,place.email,place.info from place,subcateogry where place.subcat_id=subcateogry.id And subcateogry.name='" + subcat_comboBox.SelectedItem.ToString() + "' ", con);
SqlDataReader dr = cmd.ExecuteReader();
dataGridView1.DataSource = dt;
now i want when i click on row
select coordinate_x & coordinate_y from place table where name is in row i clicked on
And store coordinate_x & coordinate_y as double
my company wrote an activeX DLL in VB6 few years back, and now i've been asked to run some tests with it.
since i dont have VB6 environment anymore, i thought it'll be best to try and make a simple C# program that will call the registered COM Dll.
to do that i copied the DLL into c:\windows\system32, used regsrv32 to register the DLL, restarted the computer and referenced to it from my project.
from there i tried working like i use to:
mydll.cMain obj = new mydll.cMain();
res = obj.SetHttpServer("www.test.com", 80);
res = obj.PingServer();
with the first method call (SetHttpServer) Everything worked fine,
on the second method call (PingServer) i keep on getting Error# 429 " ActiveX component can't create object".
i looked over the original VB class, and it seems pretty simple, it creates an HttpWebRequest object and requests a string from the webserver defined with the SetHttpServer.
that was my first thought too,
my dll depends on MSVBVM60.DLL which uses other windows DLL..
since i use Windows 7 (or Windows xp sp3 in another computer i tried) i found the file already to be located at 'system32' folder.
bytes_per_pixelS = 2;
byte stbd_data = new byte[stbd_width * num_lines * bytes_per_pixelS];
Array pingDataArray = new ushort[stbd_width * num_lines];
To assign stbd_data to pingDataArray, which one is correct, knowing that stbd_data array is twice as long as the pingDataArray....
for (int i = 0; i < stbd_width * num_lines; ++i)
pingDataArray.SetValue( BitConverter.ToUInt16 (stbd_data ,2*i),i);
for (int i = 0; i < stbd_width * num_lines; ++i)
pingDataArray.SetValue( BitConverter.ToUInt16 (stbd_data ,i),i);