|
hi
i want to call scanner program to scan an image (with code) and capture that image that scaned with scanner app,but how to do ?
|
|
|
|
|
Hi,
I have created and populated a generic collection.
This is the collection.
List<List<Test>> testCurves = new List<List<test>>();
How do I loop through this collection to the lowest hierarchy please?
|
|
|
|
|
foreach(List<Test> subList in testCurves)
{
foreach(Test t in subList)
{
}
}
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Just a suggestion: foreach loops are way slower than standard for loops.
|
|
|
|
|
I just tested it with a 1000*10000 nested List<List<int>> and Stopwatch -class, and this is the result:
Time for foreach-loop: 00:00:00.0980682
Time for for-loop: 00:00:00.0946116
I don't see a huge difference here.
Maybe the compiler is optimizing some things, like automatically converting it to a for-loop when it encounters a generic list.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
foreach is easier to maintain so unless you are dealing with large collections of data I always recommend foreach over a for loop. However, for truly large data you should consider pointers.
File Not Found
|
|
|
|
|
Hi all,
i am retuting an string array..but the errror is..
Cannot implicitly convert type 'string[]' to 'string'
Please help me, with a sample to return a basic array return
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
The error is telling you that you are trying to force a string array into a string. I assume that you are trying to return a string array, in which case the following will suffice:
public string[] GetValues()
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi i sorry, if any big blunders
i am very new to this kind of programming plese help me
actually i have collected some values from xml file and i need to disply them
so
i wrote
public string[] GetLaserProp(string laserid, string parentnode1, string childnode1)
{
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(@"E:\Dropdown_XML\laserProp.xml");
string[] str = new string[5];
// XmlNodeList xmlnodelst = xmldoc.GetElementsByTagName("laser");
XmlNodeList xmlnodelst = xmldoc.GetElementsByTagName(parentnode1);
//return xmlnodelst;
//foreach (XmlNode.parentnode in xmlnodelst)
foreach (XmlNode parentnode in xmlnodelst)
{
//MessageBox.Show(parentnode.Attributes.Item(0).Value);
if (parentnode.Attributes.Item(0).Value == laserid)
{
xmldoc.LoadXml(parentnode.InnerXml);
//XmlNodeList xmlchildnodelst=xmldoc.GetElementsByTagName("gauge");
XmlNodeList xmlchildnodelst = xmldoc.GetElementsByTagName(childnode1);
// cmbChildLaser.Items.Clear();
foreach (XmlNode childnode in xmlchildnodelst)
{
for (int i = 0; i < childnode.ChildNodes.Count; i++)
{
//cmbChildLaser.Items.Add(childnode.ChildNodes.Item(i).Attributes.Item(0).Value);
for (int j = 0; j < childnode.ChildNodes.Item(i).Attributes.Count; j++)
{
// MessageBox.Show(
str[j]= childnode.ChildNodes.Item(i).Attributes.Item(j).Value;
//cmbChildLaser.Items.Add(xmlnodelst1.Item(ii).ChildNodes.Item(0).InnerText);
return str;
}
}
}
}
}
//return (Student []) students.ToArray();}
return str;
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
Gosh! That code is very difficult to read because of all the commented out lines. This can be quite confusing.
Here is a cleaner version of the code you've supplied:
public string[] GetLaserProp(string laserid, string parentnode1, string childnode1)
{
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(@"E:\Dropdown_XML\laserProp.xml");
string[] str = new string[5];
XmlNodeList xmlnodelst = xmldoc.GetElementsByTagName(parentnode1);
foreach (XmlNode parentnode in xmlnodelst)
{
if (parentnode.Attributes.Item(0).Value == laserid)
{
xmldoc.LoadXml(parentnode.InnerXml);
XmlNodeList xmlchildnodelst = xmldoc.GetElementsByTagName(childnode1);
foreach (XmlNode childnode in xmlchildnodelst)
{
for (int i = 0; i < childnode.ChildNodes.Count; i++)
{
for (int j = 0; j < childnode.ChildNodes.Item(i).Attributes.Count; j++)
{
str[j]= childnode.ChildNodes.Item(i).Attributes.Item(j).Value;
return str;
}
}
}
}
}
return str;
}
Which line contained the error, because I cannot see anything here that would cause the error. Perhaps, as Pete suggested, the error is in the caller.
|
|
|
|
|
Colin Angus Mackay wrote: Which line contained the error, because I cannot see anything here that would cause the error.
Me neither
Colin Angus Mackay wrote: Perhaps, as Pete suggested, the error is in the caller.
agreed
modified 12-Sep-18 21:01pm.
|
|
|
|
|
You force your array to have a size of 5. What happens if you have more than 5 matches?
If you're using .NET 2, you would be better using this:
public List<string> GetLaserProp(string laserid, string parentnode1, string childnode1)
{
List<string> list = new List<string>();
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(@"E:\Dropdown_XML\laserProp.xml");
XmlNodeList xmlnodelst = xmldoc.GetElementsByTagName(parentnode1);
foreach (XmlNode parentnode in xmlnodelst)
{
if (parentnode.Attributes.Item(0).Value == laserid)
{
xmldoc.LoadXml(parentnode.InnerXml);
XmlNodeList xmlchildnodelst = xmldoc.GetElementsByTagName(childnode1);
foreach (XmlNode childnode in xmlchildnodelst)
{
for (int i = 0; i < childnode.ChildNodes.Count; i++)
{
for (int j = 0; j < childnode.ChildNodes.Item(i).Attributes.Count; j++)
{
list.Add(childnode.ChildNodes.Item(i).Attributes.Item(j).Value);
}
}
}
}
}
return list;
}
-- modified at 10:05 Wednesday 7th March, 2007
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Why not using a List<string> ?
---
single minded; short sighted; long gone;
|
|
|
|
|
I did, but the formatting got stripped out. (Show's I should preview my posts). I'll fix it ASAP.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi
I am developing a windows application in which it contains a grid. on double clicking a row on the Grid it shows all the details about that row in a new form.
If i double click the same row or other row it opens the details of respective row again in a same form.
For this i followed one logic. I take a global variable (public boolean X= false) and i am setting it true when user double clicks a row. I am resetting it in the child form. Here the value is not resetting.
What i want is Is there any mechanism or statements of code to preventing the form from openning more than one form at a time.
Please Help me.
Thanks in Advance.
Ramu Medida.
|
|
|
|
|
Open the form in modal mode. Form1.ShowDialog.
This will keep it from opening another form until this one has been closed.
Make sure you call Form1.Dispose after ShowDialog because the memory is not released when using ShowDialog as with other Show methods.
|
|
|
|
|
Instead of re-creating the child form everytime you double click on the parent form, re-use a single child form, showing or hiding it as appropriate. Before you show the form, you can use a DataView on the child form to show the data you're insterested in.
|
|
|
|
|
i would use a singleton pattern for the form
roughly:
public class MyForm:Form<br />
{<br />
private static MyForm _formInstance;<br />
private MyForm()<br />
{<br />
}<br />
public static MyForm GetFormInstance()<br />
{<br />
if (_formInstance == null) _formInstance = new MyForm();<br />
return _formInstance;<br />
}<br />
}
Hope this helps
Russell
-- modified at 4:15 Thursday 8th March, 2007
|
|
|
|
|
Thank You Very Much.
It is working for me.
Once Again Thank You.
Ramu Medida.
|
|
|
|
|
I would like to ask if it is possible to check the ports of a computer are being scanned?
I am writing a program to send out file and I would like to add a function to it by checking if that machine is being scanned by others.
May I know if C# can archieve this? Are there any samples?
Thank you very much.
|
|
|
|
|
A port scan works by attempting to open a port on a specific machine. Usually checks like this are done in the firewall(just disable port scanning). If you really want to check to see if your are being scanned the most likely place to look is in the WinSocks library functions available from Windows. They may offer such a hook. Other than that I know of no method to listen for port activity in Windows without actually creating a socket listener.
File Not Found
|
|
|
|
|
Hello,
Is there any way to restrict the DateTimePicker to display only the monthe and the year.
Dad
|
|
|
|
|
Yes, use an appropriate custom format; I use:
<br />
this.dtpDateTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom ;<br />
this.dtpDateTime.CustomFormat = "yyyy-MM-dd HH:mm:ss" ;<br />
These can be set in the designer.
--| "Every tool is a hammer." |--
|
|
|
|
|
try setting the Format property to custom and the CustomFormat proprty to "MM/yyyy" .
Hope this helps.
V.
I found a living worth working for, but haven't found work worth living for.
|
|
|
|
|
Hai friends,
i am final ME student.
i need correct implementation of multiple description coding technique in c#.
Otherwise how to use this technique
Please help because i am doing project in MANET video communication
Narayani
|
|
|
|