|
right tried that same issue, I did check with the debugger and I can't "see" anything wrong what was old say cure one bug, cause another? I thought maybe some thing was wrong with the way I positioned the code
foreach (SignedDriver driver in drivers)
{
Console.WriteLine("Driver name: {0} - Version : [1} - Date {2}",driver.DeviceName, driver.DriverVersion ?? "No version", driver.DriverDate ?? "No date");
}
I think its trying display the driver.DriverVersion before(?) "No Version" can be copied into it.
if I put
if (driver.DriverVersion == null)
driver.DriverVersion = "No version";
if (driver.DriverDate == null)
driver.DriverDate = "No Date";
I'm starting to wonder if selling the Big Issue is an option!
[EDIT]
By commenting out the Console.WriteLine() (& removing the use of the program!)
and adding the following
a++;
Console.ReadKey();
Console.WriteLine(a.ToString());
It seems to loop up to 85 produces and then shows the message for correctly finished
Console.WriteLine("Finished processing");
from creeping around the debug screen I can tell its the 85 (85th entry that causes the problem, 0 to 84) could it be due to end of the table not being done properly?
But from creeping around the debug screen I can see the driver I want at location 20 called something different in the
System.Management.ManagementObject manageObject gives the
KernelDriver,FTDIBUS,USB Serial Converter Driver
Which I thought was the driver the name it gives is:
" USB Serial Converter" the DriverVersion gives 2.8.24.0
I'm now fully confused!
modified 5-Jul-12 10:11am.
|
|
|
|
|
I have solved the issue I was having, thank you, I have learned two lessons from this
"Never Use Cut & Paste Code Directly" always look at what you are doing!,
when in stuck "have a coffee, deal with a grateful customer (they do exist at times)"
and then return to piece of code that is causing trouble. What was causing the issue
Console.WriteLine("Driver name: {0} - Version : [1} - Date {2}",
driver.DeviceName, driver.DriverVersion ?? "No version", driver.DriverDate ?? "No date"); I had stupidly copied across not really paying attention [ not {, stupid, stupid, dunces cap on! sorry Pete and thanks for the help answering my stupid questions.
|
|
|
|
|
My apologies for the bum steer. I just knocked this up in the CP message box, so I missed that. Good job though.
|
|
|
|
|
No worries, how do I up vote you as you have gone overboard helping I owe you a beer! (if you are ever in Bristol)
|
|
|
|
|
There's no need to upvote me. I'm not really that bothered about rep points. Simply mark the thread as SOLVED (edit your original post and put SOLVED at the end of the title) and that will do me.
Now, the beer on the other hand...
|
|
|
|
|
|
|
DataSet testvalue = getdata();
testvalue.Relations.Add(new DataRelation("parentChildCategories", testvalue.Tables[0].Columns["lob_parent_id"], testvalue.Tables[0].Columns["lob_id"], false));
TreeView1.DataSource = testvalue;
TreeView1.DataBind();
|
|
|
|
|
|
Was that an existential query?
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace multiplication
{
class Program
{
static void Main(string[] args)
{
int[,] a = new int[2, 2] { { 1, 2 }, { 3, 4 } };
int[,] b = new int[2, 2] { { 1, 2 }, { 3, 4 } };
int[,] c = new int[2, 2];
for (int i = 0; i <= a.Length; i++)
{
for (int j = 0; j <= b.Length; j++)
{
c[i, j] = (a[i, j] * b[i, j])+(a[i,,j+1]*b[i+1,,j]);
Console.Write(c[i, j]+ " " );
}
Console.WriteLine();
}
Console.ReadLine();
}
}
}
erorr is like
Index was outside the bounds of the array.
j somasekhar
modified 4-Jul-12 8:36am.
|
|
|
|
|
Please include the error-text, and the result that you were aiming for - ie, what should the code do?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
At first glance, there's a syntax error here (...) (a[i,,j+1]*b[i+1,,j]) (...) - note the consecutive commas, lose one of each.
Like this:
c[i, j] = (a[i, j] * b[i, j])+(a[i,j+1]*b[i+1,j]);
2A
|
|
|
|
|
For those who can't read minds, the exception you are getting is an out of bounds exception. The area that you are hitting this exception is here:
(a[i, j + 1] * b[i + 1, j]) The reason you are hitting this is because j+1 is 2 after the first iteration of j, which is outside of the bounds of the array. As I'm not sure what effect you are aiming at here, I can't really offer any concrete solution other than to say that you need to think through your logic here.
BTW - what length do you think is represented as a.Length or b.Length . It's not the 2 you're expecting; it's 4. Also, you are using <= in your conditions and it should be < only.
|
|
|
|
|
Nice catch! Have a five.
After spotting the syntax error in the code sample, I directly assumed that was the problem and stopped thinking right there...
2A
|
|
|
|
|
I spotted that error and figured it was just an error putting it into the CP editor. As soon as I saw that it was arrays and looping, I knew he'd have an out of bounds error in there somewhere. The rest was just figuring out where it was.
|
|
|
|
|
.
If that is meant to perform a matrix multiplication, then:
1.
it would require 3 nested loops, not 2, as each element (that is 2 loops) of the result matrix is to equal the inner product of one row and one column (that is the third loop, dealing with both the row of a and the column of b)
2.
I would not waste time on doing a specific case; instead use variable dimensions to make it general-purpose.
3.
And unless you want this as an exercise, there is a Matrix class that does it all for you, no hassle.
See e.g. here[^]
|
|
|
|
|
I have a stream object coming from mobile client in binary fromat as follows
name=tony&image=....raw binary representation of an image.....
I would like to extract the image out of the stream. I can extract the image and show it fine as long as string size preceding the binary image data is 16 chars or less! ("name=tony&image=") is 16 chars long
bool PostData(Stream stream)
{
using (FileStream filetoUpload = new FileStream(filePath + "ImageFromBytes.jpg", FileMode.Create))
{
byte[] byteArray = new byte[10000];
int bytesRead = 0;
bytesRead = stream.Read(byteArray, 0, byteArray.Length);
if (bytesRead > 0)
filetoUpload.Write(byteArray, 16, bytesRead-16);
....
}
}
If I do("name=randy&image=") = 17 chars long, it doesn't work, the image shows the right size, but can't be opened.
name=randy&image=....raw binary representation of an image.....
filetoUpload.Write(byteArray, 17, bytesRead-17);
Any ideas what in the world is going on?
|
|
|
|
|
I answered this question yesterday and explained that you need to parse the input stream. You cannot assume that every name will be only 4 characters long. You already have the marker characters that separate your objects (& ) and keyword value pairs (= ), so you should be scanning your input stream for those characters to split the data into its constituent parts.
|
|
|
|
|
Software2007 wrote: Any ideas what in the world is going on?
Sure - you have a randy image.
As you've discovered, you can't rely on fixed lengths in your string here - instead, you need to find the index of the second =. You can do this with string.IndexOf to find it. The good news is that you know where the first = is based on your key here, so all you need to do is use IndexOf starting on the value 5 (the position after name= in your string).
|
|
|
|
|
Pete O'Hanlon wrote: use IndexOf starting on the value 5 Not really a good suggestion based on the original question[^]. I get the impression he is trying to solve the problem by modifying the input data rather than getting to grips with the concept of parsing it.
|
|
|
|
|
Ah. I wasn't aware that he'd had an original question. Ho hum.
|
|
|
|
|
Another one that's probably going to run and run ...
|
|
|
|
|
|
Software2007 wrote: the image shows the right size
where? how?
Software2007 wrote: but can't be opened
when? by what program?
has your app exited already? did you wait a full minute and try again?
Please start taking the answers you get more seriously, and provide more detailed accurate information, so we all can help you more effectively.
|
|
|
|