|
You can't. Arrays in .NET cannot be changed once created. You can only create a new array with the new dimensions you require, then copy the data from the old array to the new one.
|
|
|
|
|
Single dimension array Vs Multiple dimension array.
- speed/performance
- memory footprint
I will be storing Object relationships and permission information so I will need to quickly return a list of Object Ids/Reference Objects inside the matrix.
I am looking for anyones experience with both types of array usages, pitfalls, performance/memory issues, and overall preferences.
Robert Fidler
I'm listening but I only speak GEEK.
|
|
|
|
|
Are you dealing with a sparse or compact matrix? Is there a natural ordering? Do you expect to reference matrix elements by integer indices? Are you going to do any matrix manipulations or is this basically just a 2D data store?
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
1. It will be a sparse matrix.
2. Natual ordering, I am not familiar with this term but after a quick google search I don't beleive I will be. Will look more like "Nested".
3. Yes I will be using an integer indices to access the matrix.
4. No matrix manipulation, I have not found a reason yet to do this. If I find that I can in the future it would be nice.
An example of useages for the matrix:
- Find all the children and childrens-children for Object.Id 456.
- Find all the parents for the Object.Id 456.
At this time it will be a simple 2D datastore of relationships.
Robert Fidler
I'm listening but I only speak GEEK.
|
|
|
|
|
By "natural ordering" I mean something that obviously has an inherent sort order, like integers, an alphabetical list, etc. Some things just "happen" almost at random and have no inherent "natural" way to order them. In your case, perhaps a user ID is (an imposed) natural ordering?
It sounds to me that you might be better off using one of the generic list-type objects to save your data, rather than an array or matrix. Your structure and application sounds like a natural for a linked list or a tree, but I'm not sure I understand enough to say for sure.
For large, sparse matrices, a list or tree would require less memory. Tree or list traversal can also be very fast compared to computing offsets in an array. As always there are trade-offs both ways.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Thanks you for you help and insight was extremely helpful, thanks again.
Robert Fidler
I'm listening but I only speak GEEK.
|
|
|
|
|
MDarray's are quite slow to index, a normal array with some funny math for the indexing is faster. But I don't really understand your requirement to return "a list inside the matrix" - what do you mean? Do you want access to rows or columns as lists?
|
|
|
|
|
harold aptroot thank you for your insight on MD Arrays.
"A list inside the matrix" is miss leading. I will have an initial datasource of Objects that I will reference by Id so once/while I iterate through the relationship matrix I can return a List<objects>.
Robert Fidler
I'm listening but I only speak GEEK.
|
|
|
|
|
HI please any one help me how to work with IRC any guide any help
please i need this i am waiting
thanks
|
|
|
|
|
Well, Bing suggests the following, for example:
http://www.ircbeginner.com/index.php[^]
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
|
Hi there
In VS2008 I type in AssemblyInfo with a period. When I do that , I see different strings representing different assemblies.
Where do these strings come from? Are these shared assemblies installed on the computer?
|
|
|
|
|
AssemblyInfo is a .Net class. What you see after the dot are its members.
|
|
|
|
|
Hello,
I am a newbie here and have an issue with a combobox. When a requestor is added, a form using a showdialog method is opened and the user is asked to enter and confirm their email address. When this is completed, the user clicks a button which adds the new requestor beautifully. It even keep that requestor as the selected one in the combobox of the request form but it places this new record at the end of the list in the combobox. The datasource of this combo is a table in an access datatabase. Can anyone help? My code with the sections of issue is below.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using Outlook = Microsoft.Office.Interop.Outlook;
using CSharp;
namespace WinSIRAD
{
public partial class frmSTDREQ : Form
{
public frmSTDREQ()
{
InitializeComponent();
}
private void frmSTDREQ_Load(object sender, EventArgs e)
{
XmlTextReader textreader2 = new XmlTextReader(Environment.CurrentDirectory.ToString() + "\\XMLFile1.xml");
textreader2.WhitespaceHandling = WhitespaceHandling.None;
while (textreader2.Read())
{
switch (textreader2.NodeType)
{
case XmlNodeType.Element:
while (textreader2.MoveToNextAttribute())
break;
OleDbConnection myconnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;" + textreader2.Value.ToString());
try
{
myconnection.Open();
}
catch
{
MessageBox.Show("Can Not Connect To The SIRAD Database!");
Application.Exit();
}
string sCmdString4 = "SELECT fldemailname,fldemailadd FROM tblAddBook ORDER BY fldemailname";
OleDbDataAdapter myadapter4 = new OleDbDataAdapter(sCmdString4, @"Provider=Microsoft.Jet.OLEDB.4.0;" + textreader2.Value.ToString());
DataTable myDT2 = new DataTable();
myadapter4.Fill(myDT2);
cboRequestor.DataSource = myDT2;
cboRequestor.DisplayMember = "fldemailname";
cboRequestor.ValueMember = "fldemailadd";
cboRequestor.SelectedIndex = -1;
myconnection.Close();
break;
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Data.OleDb;
namespace WinSIRAD
{
public partial class frmNReq : Form
{
public frmNReq()
{
InitializeComponent();
}
private void btn1NReq_Click(object sender, EventArgs e)
{
if (txtBox2.Text != "" && txtBox1.Text != "")
{
if (txtBox1.Text != txtBox2.Text)
{
MessageBox.Show("The Email Addresses Do Not Match!", "Error", MessageBoxButtons.OK);
}
else
{
XmlTextReader textreader = new XmlTextReader(Environment.CurrentDirectory.ToString() + "\\XMLFile1.xml");
textreader.WhitespaceHandling = WhitespaceHandling.None;
while (textreader.Read())
{
switch (textreader.NodeType)
{
case XmlNodeType.Element:
while (textreader.MoveToNextAttribute())
break;
//Connect to the backend via XML string
OleDbConnection myconnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;" + textreader.Value.ToString());
try
{
myconnection.Open();
}
catch
{
//If connection cannot be made then warn user and exit SIRAD
MessageBox.Show("Can Not Connect To The SIRAD Database!");
Application.Exit();
}
string sCmdString3 = "SELECT fldemailname,fldemailadd FROM tbladdbook ORDER BY fldemailname";
OleDbDataAdapter myadapter3 = new OleDbDataAdapter(sCmdString3, @"Provider=Microsoft.Jet.OLEDB.4.0;" + textreader.Value.ToString());
OleDbCommandBuilder mycb = new OleDbCommandBuilder(myadapter3);
DataTable mydt = new DataTable();
myadapter3.Fill(mydt);
DataRow dnewrow = mydt.NewRow();
dnewrow["fldemailname"] = htxtbox.Text;
dnewrow["fldemailadd"] = txtBox1.Text;
mydt.Rows.Add(dnewrow);
myadapter3.Update(mydt);
MessageBox.Show("Entry Added");
Form frm = (Form)Application.OpenForms["frmSTDREQ"];
ComboBox cb = (ComboBox)frm.Controls["cboRequestor"];
cb.Datasource = null;
cb.items.Clear();
cb.DataSource = mydt;
cb.DisplayMember = "fldemailname";
cb.ValueMember = "fldemailadd"
cb.Text = htxtbox.Text;
myconnection.Close();
this.Close();
break;
}
}
}
}
modified on Monday, May 10, 2010 1:58 PM
|
|
|
|
|
what exactly do you want help with?
Of course it gets added at the end...that's the way tables work. If you want it somewhere else, you need to implement an OrderBy in your SQL to change that.
And next time you post code, first, wrap it in pre tags. You can do this by selecting it all and hitting the "code block" button above where you are typing this message, or just adding the following opening and closing tags:
<pre lang="cs">
</pre>
Secondly, you have to tell us what the problem is and you need to identify where your problem is happening. It sounds like the code is working exactly as its supposed to. But I'm not going to read through unformatted, long code to find out what you're doing and not doing.
|
|
|
|
|
Hi Thanks for the reply!
Well I am a newbie so sorry if I am unfamiliar with posting code at this website. Secondly,my SQL does implement Orderby when the table is to be updated. So this doesn't explain why, after adding a requestor to the table and thus the combobox, the requestor is not in the proper order in the combobox.
Art
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using Outlook = Microsoft.Office.Interop.Outlook;
using CSharp;
namespace WinSIRAD
{
public partial class frmSTDREQ : Form
{
public frmSTDREQ()
{
InitializeComponent();
}
private void frmSTDREQ_Load(object sender, EventArgs e)
{
XmlTextReader textreader2 = new XmlTextReader(Environment.CurrentDirectory.ToString() + "\\XMLFile1.xml");
textreader2.WhitespaceHandling = WhitespaceHandling.None;
while (textreader2.Read())
{
switch (textreader2.NodeType)
{
case XmlNodeType.Element:
while (textreader2.MoveToNextAttribute())
break;
OleDbConnection myconnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;" + textreader2.Value.ToString());
try
{
myconnection.Open();
}
catch
{
MessageBox.Show("Can Not Connect To The SIRAD Database!");
Application.Exit();
}
string sCmdString4 = "SELECT fldemailname,fldemailadd FROM tblAddBook ORDER BY fldemailname";
OleDbDataAdapter myadapter4 = new OleDbDataAdapter(sCmdString4, @"Provider=Microsoft.Jet.OLEDB.4.0;" + textreader2.Value.ToString());
DataTable myDT2 = new DataTable();
myadapter4.Fill(myDT2);
cboRequestor.DataSource = myDT2;
cboRequestor.DisplayMember = "fldemailname";
cboRequestor.ValueMember = "fldemailadd";
cboRequestor.SelectedIndex = -1;
myconnection.Close();
break;
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Data.OleDb;
namespace WinSIRAD
{
public partial class frmNReq : Form
{
public frmNReq()
{
InitializeComponent();
}
private void btn1NReq_Click(object sender, EventArgs e)
{
if (txtBox2.Text != "" && txtBox1.Text != "")
{
if (txtBox1.Text != txtBox2.Text)
{
MessageBox.Show("The Email Addresses Do Not Match!", "Error", MessageBoxButtons.OK);
}
else
{
XmlTextReader textreader = new XmlTextReader(Environment.CurrentDirectory.ToString() + "\\XMLFile1.xml");
textreader.WhitespaceHandling = WhitespaceHandling.None;
while (textreader.Read())
{
switch (textreader.NodeType)
{
case XmlNodeType.Element:
while (textreader.MoveToNextAttribute())
break;
OleDbConnection myconnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;" + textreader.Value.ToString());
try
{
myconnection.Open();
}
catch
{
MessageBox.Show("Can Not Connect To The SIRAD Database!");
Application.Exit();
}
string sCmdString3 = "SELECT fldemailname,fldemailadd FROM tbladdbook ORDER BY fldemailname";
OleDbDataAdapter myadapter3 = new OleDbDataAdapter(sCmdString3, @"Provider=Microsoft.Jet.OLEDB.4.0;" + textreader.Value.ToString());
OleDbCommandBuilder mycb = new OleDbCommandBuilder(myadapter3);
DataTable mydt = new DataTable();
myadapter3.Fill(mydt);
DataRow dnewrow = mydt.NewRow();
dnewrow["fldemailname"] = htxtbox.Text;
dnewrow["fldemailadd"] = txtBox1.Text;
mydt.Rows.Add(dnewrow);
myadapter3.Update(mydt);
MessageBox.Show("Entry Added");
Form frm = (Form)Application.OpenForms["frmSTDREQ"];
ComboBox cb = (ComboBox)frm.Controls["cboRequestor"];
cb.Datasource = null;
cb.items.Clear();
cb.DataSource = mydt;
cb.DisplayMember = "fldemailname";
cb.ValueMember = "fldemailadd"
cb.Text = htxtbox.Text;
myconnection.Close();
this.Close();
break;
}
}
}
}
|
|
|
|
|
Any and all,
Try not to flame me, I'm a EE that writes C# sparingly, so go easy on me.
I have an application with a property grid and a data grid view. The data grid represents a register table of an ASIC. A register location inside the ASIC controls some portion of the ASIC. The property grid contains the same control as the register table, only in a more easy to use manner, as you can imagine.
The user can alter a property which in turn writes a register in the ASIC, this register change fires the data grid to update, via reading all the registers in the ASIC. The reverse is also possible: the user may manually change a register which updates the data grid and then the property grid is updated.
If I explained myself well enough, the data grid and property grids are tied together via control of the ASIC. Currently, if a property is changed I have a big case statement with the property name as the switch. Depending on which property is updated I then alter the specific register.
Currently, if a register is manually written (via the data grid) I have another big case statement with the register address as the switch. I then update the necessary property in the property grid.
My question is there must be a better way of doing this. As you can imagine every time I port my software to a new or different ASIC I have to re-write ~1000 lines of code. Also a property can affect multiple registers, which in turn can affect other properties, i.e. Prop A Changed->Write Register B, C, & D->Update data grid->Register D Changed->Update property A & E->etc. These "callbacks" can get long & slow down my application. What can I do to make this process more seemless?
FYI I can't completely remove the data grid view, because of other reasons, even though I believe users use the PropertyGrid > 98% of the time.
Thanks,
--RB
|
|
|
|
|
i want to save a TreeView in database
i designed a table with three fields (ID , NodeName,UpareNodeID)
and create a relation ship with ID and UpareNodeID is it correct?
if it is , how can i retrieve thees nodes with the best performance ?
i want to know if there is a better solution to save and retrieve this kind of collection
thanks!
modified on Monday, May 10, 2010 12:08 PM
|
|
|
|
|
|
Where you are retrieving the data to populate the treeview, you should look at lazy loading it. In other words, if you have a deep hierarchy with lots of records, you can improve the responsiveness of your application and the overall feel for your users just by loading data as it's needed.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
You may use XML for this with succes!
Give it a try. Good luck!
Alex Manolescu
|
|
|
|
|
calculated with the formula I want to put a space variable. Then I'd like to collect these variables.
for example :
v1 = x1 * y1 / z3
global numbervar v1;
sum (v1)
|
|
|
|
|
Hi
I have two pieces of software communicating over a TCP/IP, one is written in MFC and the other one in C#.In MFC I use memcpy to copy the hole structures to a byte array and send it to the other software, and when receiving data in MFC I use memcpy as well to align each bit to its variable
example
typedef struct<br />
{<br />
unsigned int ID;<br />
unsigned int SequenceNumber;<br />
unsigned int ReferenceSeqNumber;<br />
} HeaderType;<br />
<br />
HeaderType header;<br />
<br />
memcpy(&header,&byteArray,sizeof(HeaderType));
but in C# I have no clue how to do this, and if not possible, then what is the best way to extract these variables?
Thanks in advance
Abdulaziz
|
|
|
|
|
|