lancerxe
asked on
Not getting a value from a 1 dimentional array
Hello experts:
Can someone please tell me why the code snippet below does not work.
The loop works and it populates RecContent just fine
but LDAcctNo is not populated
for (intCounter = 0; intCounter <= intLastElement; intCounter++)
{
RecContent = LoanDetArray.GetValue (intCounter).ToString();
LDAcctNo = RecContent.ToCharArray(0,2 0).ToStrin g();
}
Thanks
Can someone please tell me why the code snippet below does not work.
The loop works and it populates RecContent just fine
but LDAcctNo is not populated
for (intCounter = 0; intCounter <= intLastElement; intCounter++)
{
RecContent = LoanDetArray.GetValue (intCounter).ToString();
LDAcctNo = RecContent.ToCharArray(0,2
}
Thanks
ASKER
Everytime the RecContent is populated I need to
get the LDAcctNo also
How can I make the LDAcctNo = RecContent.ToCharArray(0,2 0).ToStrin g();
part of the loop?
get the LDAcctNo also
How can I make the LDAcctNo = RecContent.ToCharArray(0,2
part of the loop?
I think i mist the point,
I just tried your code,
do you get a exception ???
you do not check the length of RecCont.
change the code to
LDAcctNo = RecContent.ToCharArray(0, Math.Min(20,RecContent.Len gth)).ToSt ring();
I hope that this is your problem
what are the types of LDAcctNo and RecContent ??
Ad
I just tried your code,
do you get a exception ???
you do not check the length of RecCont.
change the code to
LDAcctNo = RecContent.ToCharArray(0, Math.Min(20,RecContent.Len
I hope that this is your problem
what are the types of LDAcctNo and RecContent ??
Ad
ASKER
I don't get an exception
but when I step thru the code
RecContent gets populated and the 1st record has accountnumber 00000000000000000001
but LDAcctNo does not.
When I put the cursor on top of it , it says "System.Char[]". I was expecting to see 00000000000000000001
I get this error with my original code or your code.
Both are strings
but when I step thru the code
RecContent gets populated and the 1st record has accountnumber 00000000000000000001
but LDAcctNo does not.
When I put the cursor on top of it , it says "System.Char[]". I was expecting to see 00000000000000000001
I get this error with my original code or your code.
Both are strings
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That was it
Thanks
Thanks
If I look at your code you are filling RecContent in a loop
you must assign LDAcctNo after you have finished de loop
for (intCounter = 0; intCounter <= intLastElement; intCounter++)
{
RecContent = LoanDetArray.GetValue (intCounter).ToString();
}
LDAcctNo = RecContent.ToCharArray(0,2
Ad