The array is allocated on the heap. But really, you can't think of the .NET heap the same way as in C or C++. Allocating a new object on the heap CAN be, but not always, faster then allocating memory on the stack in .NET.
When a .NET application starts, a chunk of memory is allocated as the heap. So the memory is already allocated, when an object is created with the 'new' keyword, that object is given preallocated memory on the .NET...
User Profile
Collapse
-
-
That object is an object of type you want to cast your byte array to. There is another way so you don't need that object.
Code:static object ByteArrayToStructure(byte[] bytearray) { IntPtr ptr = IntPtr.Zero; try { ptr = Marshal.AllocHGlobal(bytearray.Length); Marshal.Copy(bytearray, 0, ptr, bytearray.Length); return Marshal.PtrToStructure(ptr,
Leave a comment:
-
The label control does have the properties Left and Top. They are hidden from the designer. You can also do it this way:
Code:label1.Location = new Point(100, 50);
Leave a comment:
-
Try this:
Code:Public Class Form1 Private Delegate Sub SetTextCallback(ByVal text As String) Private form2 As Form2 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load form2 = New Form2 form2.Show() form2.BringToFront() signal = New Class1() End Sub
Leave a comment:
-
The best approach to this would be to create an event in Class1 that gets raised whenever you want to indicate progress from your thread.
Code:For i As Integer = 0 To 5 Threading.Thread.Sleep(5000) ' Form2.Label1.Text = i.ToString ' singal event here Next
Leave a comment:
-
Here is another way you can do this without using the Controls.Find method:
Code:string labelToHide = "Label" + ind; if(this.Controls.ContainsKey(labelToHide)) { this.Controls[labelToHide].Visible = false; }
Leave a comment:
-
This indicates that Me.cbDefault is a ComboBox and the property NewIndex doesn't exist for Me.cbDefault.
I am not sure exactly what you are trying to do, but if you want to get the index for the selected item in the combobox, change it to:
Code:If Default_Renamed = True Then ListIndex = Me.cbDefault.SelectedIndex
Leave a comment:
-
The following should open your dataManage folder and add the key-value pairs.
Code:RegistryKey local = Registry.LocalMachine; local = local.OpenSubKey("SOFTWARE\\dataManage", true); local.SetValue("emp", "dipa"); local.SetValue("id", 23); local.SetValue("add", "mum");
Leave a comment:
-
Also, any classes/functions that are declared internal can't be accessed outside of that assembly.Leave a comment:
-
-
Right after you do your insert you can do:
Code:INSERT INTO tblOrders (custname, custdetails, orderdate) VALUES (@custname, @custdetails, @orderdate) SET @OrderID = SCOPE_IDENTITY()
http://davidhayden.com/blog/dave/arc...2/16/2803.aspx...Leave a comment:
-
There is a WebBrowser control that should be in your Toolbox under Common Controls in VS. You can pass some URL or you could store your HTML to a local file, and then pass the local path as the Uri of the WebBrowser control.Leave a comment:
-
This should get you started
Code:using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication2 { public class Form1 : Form { private System.Windows.Forms.StatusStrip statusStrip1; private System.Windows.Forms.ToolStripProgressBar
Leave a comment:
-
You will have to make EPType public. However, you can prevent assemblies outside of that one from inheriting your base type, by making an internal constructor.
Code:public abstract class EPType { private String m_Name; public String Name { get { return m_Name; } } internal EPType(String Name) {
Leave a comment:
-
Unfortunetly the Acrobat Reader ActiveX is very limited. You can however hide the toolbars:
Code:axAcroPDF1.setShowToolbar(false);
Leave a comment:
-
I am not sure if this will help, but based on the example above, you need to write it as:
Code:int a = 10; string b = "test"; public string MyMethod(object o){ // get the object and add 1; return o.ToString() + "1"; } string output1 = MyMethod(a); // 101 string output2 = MyMethod(b); // test1
Leave a comment:
-
That is the thing with the BinaryFormatter , it reads the entire stream that is provided to the Deserialize function. So you would have to write blocks of bytes from a file to a MemoryStream and pass that to the BinaryFormatter ....Leave a comment:
-
He is correct, you don't need the BinaryReader. You can simply do:
Code:using(FileStream fs = new FileStream(filePath, FileMode.Open)) { byte[] buffer = new byte[fs.Length]; fs.Read(buffer, 0, fs.Length); }
Leave a comment:
-
The FileSystemWatch er runs on a seperate thread, when you try to set the value of your TextBox .NET doesn't allow you to access the control from another thread, and will throw the exception you just specified.
What you need to do is call back to the main thread that your UI is running on. Here is an example on how you can accomplish this.
[CODE=vbnet]
Private Delegate Sub FileWatcherCall back(ByVal e As FileSystemEvent Args)...Leave a comment:
-
You will somehow need to know the byte length of each object serialized in your file, I am assuming you are using binary serialization. The problem with this is each searialized object won't have the same byte length if you are serializing non-fixed length objects such as strings.
If you want everything in a single file, you can serialize your object into a MemoryStream, figure out the length, write the first 4 bytes in your file...Leave a comment:
No activity results to display
Show More
Leave a comment: