|
List and Dictionary are meant for completely different purposes. It's like saying which is best, Beethoven or a horse? You store the objects in the container that best fits your needs. So, if you need a keyed lookup of your objects for efficient retrieval, a Dictionary is a better bet than a List. If, however, all you need is somewhere to store data and you aren't that bothered about searching for it, a List is a good choice.
|
|
|
|
|
thanks for the explanations and for the great article about dictionarys.
if(this.signature != "")
{
MessageBox.Show("This is my signature: " + Environment.NewLine + signature);
}
else
{
MessageBox.Show("404-Signature not found");
}
|
|
|
|
|
Just to add to Pete's answer, you might want to Google for tutorials on "data structures" (which both Lists and Dictionaries are). Each has it own uses, and you can save yourself a stack* of work using the correct one. In my experience List and Dictionary are the two I most commonly use c#, but YMMV, it's worth knowning about the others.
*intended.
|
|
|
|
|
Pete O'Hanlon wrote: List and Dictionary are meant for completely different purposes. It's like saying which is best, Beethoven or a horse? +500
/ravi
|
|
|
|
|
It's often the case that where you want a mapping between items of different Types, such as ListViewItems in a ListView, and instances of your own Classes, that a Dictionary is a very convenient way to enable rapid access from an instance of one Type to the related instance of the other Type ... without casting, or too-clever coding.
A good example would be a combination ListView and TreeView Control: by keeping a Dictionary<ListViewItem, TreeNode>, and a "symmetric" Dictionary<TreeNode, ListViewItem>, you can rapidly synchronize the selection in both TreeView and ListView without translating indexes from one to the other, casting, etc.
"What Turing gave us for the first time (and without Turing you just couldn't do any of this) is he gave us a way of thinking about and taking seriously and thinking in a disciplined way about phenomena that have, as I like to say, trillions of moving parts.
Until the late 20th century, nobody knew how to take seriously a machine with a trillion moving parts. It's just mind-boggling." Daniel C. Dennett
|
|
|
|
|
i wanna to show this xml in textbox (same as .xml file) (xml format) and be able to edit it and save.
note : if possible to import this xml to Datagridview:
DataSet ds = new DataSet();
StringReader rr = new StringReader("<root> <steps><step number=\"1\"><positions><position id=\"21\" /><position id=\"19\" /></positions><persons><person id=\"37\" position=\"21\"><systemfolder>4</systemfolder><controls><control fieldname=\"قسمت درخواست مرخصي\" fieldlatinname=\"request part for vacation\" fieldcontrolname=\"pnldarkhast\" editable=\"true\" visible=\"true\" /><control fieldname=\"بخش مربوط به مدير قسمت\" fieldlatinname=\"supervisor part\" fieldcontrolname=\"pnlmodir\" editable=\"false\" visible=\"false\" /><control fieldname=\"چرخه دارد\" fieldlatinname=\"is workflow\" fieldcontrolname=\"checkbox_isworkflow\" editable=\"false\" visible=\"false\" /><control fieldname=\"قسمت مربوط به کار گزيني\" fieldlatinname=\"human resource part\" fieldcontrolname=\"pnlkargozeni\" editable=\"false\" visible=\"false\" /><control fieldname=\"ساعت باقي مانده\" fieldlatinname=\"remain hours\" fieldcontrolname=\"pnlvacationhoursremain\" editable=\"false\" visible=\"true\" /></controls><permissions><activities><start>false</start><pause>false</pause><stop>false</stop></activities><backpermission>False</backpermission><selectablepersons>False</selectablepersons><selectableSender>False</selectableSender><selectableStarter>False</selectableStarter><ViewProcess>False</ViewProcess><ViewFinalTillNow>False</ViewFinalTillNow><CanSendToOthers>False</CanSendToOthers><attachfile>True</attachfile></permissions></person><person id=\"28\" position=\"19\"><systemfolder>4</systemfolder><controls><control fieldname=\"قسمت درخواست مرخصي\" fieldlatinname=\"request part for vacation\" fieldcontrolname=\"pnldarkhast\" editable=\"true\" visible=\"true\" /><control fieldname=\"بخش مربوط به مدير قسمت\" fieldlatinname=\"supervisor part\" fieldcontrolname=\"pnlmodir\" editable=\"false\" visible=\"false\" /><control fieldname=\"چرخه دارد\" fieldlatinname=\"is workflow\" fieldcontrolname=\"checkbox_isworkflow\" editable=\"false\" visible=\"false\" /><control fieldname=\"قسمت مربوط به کار گزيني\" fieldlatinname=\"human resource part\" fieldcontrolname=\"pnlkargozeni\" editable=\"false\" visible=\"false\" /><control fieldname=\"ساعت باقي مانده\" fieldlatinname=\"remain hours\" fieldcontrolname=\"pnlvacationhoursremain\" editable=\"false\" visible=\"true\" /></controls><permissions><activities><start>false</start><pause>false</pause><stop>false</stop></activities><backpermission>False</backpermission><selectablepersons>False</selectablepersons><selectableSender>False</selectableSender><selectableStarter>False</selectableStarter><ViewProcess>False</ViewProcess><ViewFinalTillNow>False</ViewFinalTillNow><CanSendToOthers>False</CanSendToOthers><attachfile>True</attachfile></permissions></person></persons><stepvalidation><conditionfields>37,28,28</conditionfields><conditionexpression></conditionexpression></stepvalidation></step><step number=\"2\"><positions><position id=\"23\" /></positions><persons><person id=\"53\" position=\"23\"><systemfolder>2</systemfolder><controls><control fieldname=\"قسمت درخواست مرخصي\" fieldlatinname=\"request part for vacation\" fieldcontrolname=\"pnldarkhast\" editable=\"false\" visible=\"true\" /><control fieldname=\"بخش مربوط به مدير قسمت\" fieldlatinname=\"supervisor part\" fieldcontrolname=\"pnlmodir\" editable=\"true\" visible=\"true\" /><control fieldname=\"چرخه دارد\" fieldlatinname=\"is workflow\" fieldcontrolname=\"checkbox_isworkflow\" editable=\"false\" visible=\"false\" /><control fieldname=\"قسمت مربوط به کار گزيني\" fieldlatinname=\"human resource part\" fieldcontrolname=\"pnlkargozeni\" editable=\"false\" visible=\"false\" /><control fieldname=\"ساعت باقي مانده\" fieldlatinname=\"remain hours\" fieldcontrolname=\"pnlvacationhoursremain\" editable=\"false\" visible=\"false\" /></controls><permissions><activities><start>true</start><pause>true</pause><stop>true</stop></activities><backpermission>True</backpermission><selectablepersons>False</selectablepersons><selectableSender>False</selectableSender><selectableStarter>True</selectableStarter><ViewProcess>False</ViewProcess><ViewFinalTillNow>False</ViewFinalTillNow><CanSendToOthers>False</CanSendToOthers><attachfile>False</attachfile></permissions></person></persons><stepvalidation><conditionfields>53</conditionfields><conditionexpression></conditionexpression></stepvalidation></step><finish number=\"0\"><positions><position id=\"7\" /><position id=\"3\" /></positions><persons><person id=\"30\" position=\"7\"><systemfolder>2</systemfolder><controls /><permissions><activities><start>false</start><pause>false</pause><stop>false</stop></activities><backpermission>False</backpermission><selectablepersons>False</selectablepersons><selectableSender>False</selectableSender><selectableStarter>False</selectableStarter><ViewProcess>False</ViewProcess><ViewFinalTillNow>False</ViewFinalTillNow><CanSendToOthers>False</CanSendToOthers><attachfile>False</attachfile></permissions></person><person id=\"56\" position=\"3\"><systemfolder>2</systemfolder><controls /><permissions><activities><start>false</start><pause>false</pause><stop>false</stop></activities><backpermission>False</backpermission><selectablepersons>False</selectablepersons><selectableSender>False</selectableSender><selectableStarter>False</selectableStarter><ViewProcess>False</ViewProcess><ViewFinalTillNow>False</ViewFinalTillNow><CanSendToOthers>False</CanSendToOthers><attachfile>False</attachfile></permissions></person></persons><message>Request_Denied</message></finish><enduser><systemfolder>0</systemfolder></enduser></steps> </root> ");
ds.ReadXml(rr);<br />
StringBuilder sb = new StringBuilder();<br />
ds.WriteXml(new StringWriter(sb));<br />
i get error while importing it to datagridview.<br />
Cannot add a column named 'controls': a nested table with the same name already belongs to this DataTable.<br />
<root> <steps><step number="1"><positions><position id="21" /><position id="19" /></positions><persons><person id="37" position="21"><systemfolder>4</systemfolder><controls><control fieldname="قسمت درخواست مرخصي" fieldlatinname="request part for vacation" fieldcontrolname="pnldarkhast" editable="true" visible="true" /><control fieldname="بخش مربوط به مدير قسمت" fieldlatinname="supervisor part" fieldcontrolname="pnlmodir" editable="false" visible="false" /><control fieldname="چرخه دارد" fieldlatinname="is workflow" fieldcontrolname="checkbox_isworkflow" editable="false" visible="false" /><control fieldname="قسمت مربوط به کار گزيني" fieldlatinname="human resource part" fieldcontrolname="pnlkargozeni" editable="false" visible="false" /><control fieldname="ساعت باقي مانده" fieldlatinname="remain hours" fieldcontrolname="pnlvacationhoursremain" editable="false" visible="true" /></controls><permissions><activities><start>false</start><pause>false</pause><stop>false</stop></activities><backpermission>False</backpermission><selectablepersons>False</selectablepersons><selectableSender>False</selectableSender><selectableStarter>False</selectableStarter><ViewProcess>False</ViewProcess><ViewFinalTillNow>False</ViewFinalTillNow><CanSendToOthers>False</CanSendToOthers><attachfile>True</attachfile></permissions></person><person id="28" position="19"><systemfolder>4</systemfolder><controls><control fieldname="قسمت درخواست مرخصي" fieldlatinname="request part for vacation" fieldcontrolname="pnldarkhast" editable="true" visible="true" /><control fieldname="بخش مربوط به مدير قسمت" fieldlatinname="supervisor part" fieldcontrolname="pnlmodir" editable="false" visible="false" /><control fieldname="چرخه دارد" fieldlatinname="is workflow" fieldcontrolname="checkbox_isworkflow" editable="false" visible="false" /><control fieldname="قسمت مربوط به کار گزيني" fieldlatinname="human resource part" fieldcontrolname="pnlkargozeni" editable="false" visible="false" /><control fieldname="ساعت باقي مانده" fieldlatinname="remain hours" fieldcontrolname="pnlvacationhoursremain" editable="false" visible="true" /></controls><permissions><activities><start>false</start><pause>false</pause><stop>false</stop></activities><backpermission>False</backpermission><selectablepersons>False</selectablepersons><selectableSender>False</selectableSender><selectableStarter>False</selectableStarter><ViewProcess>False</ViewProcess><ViewFinalTillNow>False</ViewFinalTillNow><CanSendToOthers>False</CanSendToOthers><attachfile>True</attachfile></permissions></person></persons><stepvalidation><conditionfields>37,28,28</conditionfields><conditionexpression></conditionexpression></stepvalidation></step><step number="2"><positions><position id="23" /></positions><persons><person id="53" position="23"><systemfolder>2</systemfolder><controls><control fieldname="قسمت درخواست مرخصي" fieldlatinname="request part for vacation" fieldcontrolname="pnldarkhast" editable="false" visible="true" /><control fieldname="بخش مربوط به مدير قسمت" fieldlatinname="supervisor part" fieldcontrolname="pnlmodir" editable="true" visible="true" /><control fieldname="چرخه دارد" fieldlatinname="is workflow" fieldcontrolname="checkbox_isworkflow" editable="false" visible="false" /><control fieldname="قسمت مربوط به کار گزيني" fieldlatinname="human resource part" fieldcontrolname="pnlkargozeni" editable="false" visible="false" /><control fieldname="ساعت باقي مانده" fieldlatinname="remain hours" fieldcontrolname="pnlvacationhoursremain" editable="false" visible="false" /></controls><permissions><activities><start>true</start><pause>true</pause><stop>true</stop></activities><backpermission>True</backpermission><selectablepersons>False</selectablepersons><selectableSender>False</selectableSender><selectableStarter>True</selectableStarter><ViewProcess>False</ViewProcess><ViewFinalTillNow>False</ViewFinalTillNow><CanSendToOthers>False</CanSendToOthers><attachfile>False</attachfile></permissions></person></persons><stepvalidation><conditionfields>53</conditionfields><conditionexpression></conditionexpression></stepvalidation></step><finish number="0"><positions><position id="7" /><position id="3" /></positions><persons><person id="30" position="7"><systemfolder>2</systemfolder><controls /><permissions><activities><start>false</start><pause>false</pause><stop>false</stop></activities><backpermission>False</backpermission><selectablepersons>False</selectablepersons><selectableSender>False</selectableSender><selectableStarter>False</selectableStarter><ViewProcess>False</ViewProcess><ViewFinalTillNow>False</ViewFinalTillNow><CanSendToOthers>False</CanSendToOthers><attachfile>False</attachfile></permissions></person><person id="56" position="3"><systemfolder>2</systemfolder><controls /><permissions><activities><start>false</start><pause>false</pause><stop>false</stop></activities><backpermission>False</backpermission><selectablepersons>False</selectablepersons><selectableSender>False</selectableSender><selectableStarter>False</selectableStarter><ViewProcess>False</ViewProcess><ViewFinalTillNow>False</ViewFinalTillNow><CanSendToOthers>False</CanSendToOthers><attachfile>False</attachfile></permissions></person></persons><message>Request_Denied</message></finish><enduser><systemfolder>0</systemfolder></enduser></steps> </root>
|
|
|
|
|
Please adjust the formatting and clarify your question.
Veni, vidi, caecus
|
|
|
|
|
How are you connecting your data to the datagridview?
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
|
I would read the XML into the dataset and then use the dataset to display the data in the grid
i.e.
DatagridviewName.DataSource = ds.Tables[0];
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
have you used my xml??
thanks inn advanced!
|
|
|
|
|
Do you have a schema for this XML?
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
<root> <steps><step number="1"><positions><position id="21" /><position id="19" /></positions><persons><person id="37" position="21"><systemfolder>4</systemfolder><controls><control fieldname="قسمت درخواست مرخصي" fieldlatinname="request part for vacation" fieldcontrolname="pnldarkhast" editable="true" visible="true" /><control fieldname="بخش مربوط به مدير قسمت" fieldlatinname="supervisor part" fieldcontrolname="pnlmodir" editable="false" visible="false" /><control fieldname="چرخه دارد" fieldlatinname="is workflow" fieldcontrolname="checkbox_isworkflow" editable="false" visible="false" /><control fieldname="قسمت مربوط به کار گزيني" fieldlatinname="human resource part" fieldcontrolname="pnlkargozeni" editable="false" visible="false" /><control fieldname="ساعت باقي مانده" fieldlatinname="remain hours" fieldcontrolname="pnlvacationhoursremain" editable="false" visible="true" /></controls><permissions><activities><start>false</start><pause>false</pause><stop>false</stop></activities><backpermission>False</backpermission><selectablepersons>False</selectablepersons><selectableSender>False</selectableSender><selectableStarter>False</selectableStarter><ViewProcess>False</ViewProcess><ViewFinalTillNow>False</ViewFinalTillNow><CanSendToOthers>False</CanSendToOthers><attachfile>True</attachfile></permissions></person><person id="28" position="19"><systemfolder>4</systemfolder><controls><control fieldname="قسمت درخواست مرخصي" fieldlatinname="request part for vacation" fieldcontrolname="pnldarkhast" editable="true" visible="true" /><control fieldname="بخش مربوط به مدير قسمت" fieldlatinname="supervisor part" fieldcontrolname="pnlmodir" editable="false" visible="false" /><control fieldname="چرخه دارد" fieldlatinname="is workflow" fieldcontrolname="checkbox_isworkflow" editable="false" visible="false" /><control fieldname="قسمت مربوط به کار گزيني" fieldlatinname="human resource part" fieldcontrolname="pnlkargozeni" editable="false" visible="false" /><control fieldname="ساعت باقي مانده" fieldlatinname="remain hours" fieldcontrolname="pnlvacationhoursremain" editable="false" visible="true" /></controls><permissions><activities><start>false</start><pause>false</pause><stop>false</stop></activities><backpermission>False</backpermission><selectablepersons>False</selectablepersons><selectableSender>False</selectableSender><selectableStarter>False</selectableStarter><ViewProcess>False</ViewProcess><ViewFinalTillNow>False</ViewFinalTillNow><CanSendToOthers>False</CanSendToOthers><attachfile>True</attachfile></permissions></person></persons><stepvalidation><conditionfields>37,28,28</conditionfields><conditionexpression></conditionexpression></stepvalidation></step><step number="2"><positions><position id="23" /></positions><persons><person id="53" position="23"><systemfolder>2</systemfolder><controls><control fieldname="قسمت درخواست مرخصي" fieldlatinname="request part for vacation" fieldcontrolname="pnldarkhast" editable="false" visible="true" /><control fieldname="بخش مربوط به مدير قسمت" fieldlatinname="supervisor part" fieldcontrolname="pnlmodir" editable="true" visible="true" /><control fieldname="چرخه دارد" fieldlatinname="is workflow" fieldcontrolname="checkbox_isworkflow" editable="false" visible="false" /><control fieldname="قسمت مربوط به کار گزيني" fieldlatinname="human resource part" fieldcontrolname="pnlkargozeni" editable="false" visible="false" /><control fieldname="ساعت باقي مانده" fieldlatinname="remain hours" fieldcontrolname="pnlvacationhoursremain" editable="false" visible="false" /></controls><permissions><activities><start>true</start><pause>true</pause><stop>true</stop></activities><backpermission>True</backpermission><selectablepersons>False</selectablepersons><selectableSender>False</selectableSender><selectableStarter>True</selectableStarter><ViewProcess>False</ViewProcess><ViewFinalTillNow>False</ViewFinalTillNow><CanSendToOthers>False</CanSendToOthers><attachfile>False</attachfile></permissions></person></persons><stepvalidation><conditionfields>53</conditionfields><conditionexpression></conditionexpression></stepvalidation></step><finish number="0"><positions><position id="7" /><position id="3" /></positions><persons><person id="30" position="7"><systemfolder>2</systemfolder><controls /><permissions><activities><start>false</start><pause>false</pause><stop>false</stop></activities><backpermission>False</backpermission><selectablepersons>False</selectablepersons><selectableSender>False</selectableSender><selectableStarter>False</selectableStarter><ViewProcess>False</ViewProcess><ViewFinalTillNow>False</ViewFinalTillNow><CanSendToOthers>False</CanSendToOthers><attachfile>False</attachfile></permissions></person><person id="56" position="3"><systemfolder>2</systemfolder><controls /><permissions><activities><start>false</start><pause>false</pause><stop>false</stop></activities><backpermission>False</backpermission><selectablepersons>False</selectablepersons><selectableSender>False</selectableSender><selectableStarter>False</selectableStarter><ViewProcess>False</ViewProcess><ViewFinalTillNow>False</ViewFinalTillNow><CanSendToOthers>False</CanSendToOthers><attachfile>False</attachfile></permissions></person></persons><message>Request_Denied</message></finish><enduser><systemfolder>0</systemfolder></enduser></steps> </root>
|
|
|
|
|
That's not a schema. That's just an XML dump.
|
|
|
|
|
So how can i do that ?
i mean show in correct XML format or even in datagridview?
|
|
|
|
|
I have found a lot of answers over net but none of them worked for me.
I have,
1) Windows 7 64-bit
2) Visual Studio 2012
3) .net framework 4.5
4) libemgucv-windows-universal-cuda-2.9.0.1922-beta.exe
5) OpenCV-2.4.7.exe
Please suggest me how to resolve this.
|
|
|
|
|
Please do not repost the same question.
Veni, vidi, abiit domum
|
|
|
|
|
Edit: Moved to thread below.
Veni, vidi, caecus
|
|
|
|
|
Basically you are trying to use a 32 bit DLL compiled as a 32 bit target inside an application that's running in 64 bit. You have two choices - give your application 32 bit affinity or give it a 64 bit version of the 32 bit Dlls.
To give your app 32 bit affinity, you need to do the following steps for every project in your solution.
In Solution Explorer, right click on your project name and select Properties from the bottom of the list (or just select the project name and click Alt+Enter). You will now see the project property pages. Select the Build tab and change the Platform target from Any CPU to x86.
|
|
|
|
|
I have found a lot of answers over net but none of them worked for me.
I have,
1) Visual Studio 2012
2) .net framework 4.5
3) libemgucv-windows-universal-cuda-2.9.0.1922-beta.exe
4) OpenCV-2.4.7.exe
5) Windows 7 64-bit
Please suggest me how to resolve this.
|
|
|
|
|
1. What is the actual code that causes the exception, including context.
2. What exception is being thrown.
Veni, vidi, abiit domum
|
|
|
|
|
Please provide further explanation.
We can't view your screen, nor can we access your HDD (we are not the NSA, after all).
Please provide us the following information:
- Full exception text
- Inner exception text
- Code Snippet where the exception happens, with sufficient additional code around it in order to understand what may be going on
- Maybe it happens because of the beta version? -> Verify with stable version of libemgucv
Veni, vidi, caecus
|
|
|
|
|
The type initializer for 'Emgu.CV.CvInvoke' threw an exception.
Message : An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
|
|
|
|
|
An "incorrect format" error usually means you're trying to load a 32-bit assembly in a 64-bit program, or vice-versa.
There are also some suggestions in this QA thread[^] and this SO question[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
<b>Finally problem resolved.</b>
Just uninstalled emgucv, fixed dll's using ccleaner (as played with dll's a lot), system rerstarted, installed emgucv 2.2 (I guess most stable version).
|
|
|
|