473,387 Members | 1,420 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Length of string in array

I have an array of strings

string[] strArray = new string[10];

strArray[5] = "ABC";

How can I determine the number of characters in the array item?

if (strArray[5].length = = 3)
{
}

This is acually returning 10 which is the array length

I want the array item string.length

Thanks

Michael
Nov 16 '05 #1
5 1876
That is correct though...

Console.WriteLine(strArray[5].Length);

That should return 3.

Maybe you called strArray.Length without an indexer?

--
HTH

Kyril Magnos
"I'm not a developer anymore, I'm a software engineer now!" :-)

"Michael C" <as***@askme.com> wrote in message
news:Or**************@tk2msftngp13.phx.gbl...
|I have an array of strings
|
| string[] strArray = new string[10];
|
| strArray[5] = "ABC";
|
| How can I determine the number of characters in the array item?
|
| if (strArray[5].length = = 3)
| {
| }
|
| This is acually returning 10 which is the array length
|
| I want the array item string.length
|
| Thanks
|
| Michael
|
|
Nov 16 '05 #2
Maybe try something like (strArray[5]).Length.
"Michael C" <as***@askme.com> wrote in message
news:Or**************@tk2msftngp13.phx.gbl...
I have an array of strings

string[] strArray = new string[10];

strArray[5] = "ABC";

How can I determine the number of characters in the array item?

if (strArray[5].length = = 3)
{
}

This is acually returning 10 which is the array length

I want the array item string.length

Thanks

Michael

Nov 16 '05 #3
> Maybe try something like (strArray[5]).Length.

This should make no difference, does it :)

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
"Peter Rilling" <pe***@nospam.rilling.net> schrieb im Newsbeitrag
news:ei**************@TK2MSFTNGP11.phx.gbl...
Maybe try something like (strArray[5]).Length.
"Michael C" <as***@askme.com> wrote in message
news:Or**************@tk2msftngp13.phx.gbl...
I have an array of strings

string[] strArray = new string[10];

strArray[5] = "ABC";

How can I determine the number of characters in the array item?

if (strArray[5].length = = 3)
{
}

This is acually returning 10 which is the array length

I want the array item string.length

Thanks

Michael


Nov 16 '05 #4
You are right that it should not, but since the problem was that Length was
being applied to the array rather then the array element, this was all that
I could think of. There is nothing like being explicit when troubleshooting
code.
"cody" <no****************@gmx.net> wrote in message
news:u4**************@TK2MSFTNGP11.phx.gbl...
Maybe try something like (strArray[5]).Length.


This should make no difference, does it :)

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
"Peter Rilling" <pe***@nospam.rilling.net> schrieb im Newsbeitrag
news:ei**************@TK2MSFTNGP11.phx.gbl...
Maybe try something like (strArray[5]).Length.
"Michael C" <as***@askme.com> wrote in message
news:Or**************@tk2msftngp13.phx.gbl...
I have an array of strings

string[] strArray = new string[10];

strArray[5] = "ABC";

How can I determine the number of characters in the array item?

if (strArray[5].length = = 3)
{
}

This is acually returning 10 which is the array length

I want the array item string.length

Thanks

Michael



Nov 16 '05 #5
Peter Rilling <pe***@nospam.rilling.net> wrote:
You are right that it should not, but since the problem was that
Length was being applied to the array rather then the array element,
this was all that I could think of. There is nothing like being
explicit when troubleshooting code.


I think the problem is that we weren't seeing the actual code. The code
posted certainly wouldn't compile (due to the space in the comparison)
so I suspect it wasn't the real code.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Robert Mark Bram | last post by:
Hi All! How do you get the length of an associative array? var my_cars= new Array() my_cars="Mustang"; my_cars="Station Wagon"; my_cars="SUV"; alert(my_cars.length);
12
by: arkobose | last post by:
my earlier post titled: "How to input strings of any lengths into arrays of type: char *array ?" seems to have created a confusion. therefore i paraphrase my problem below. consider the...
2
by: Dmitri Shvetsov | last post by:
Hi All, Does somebody know what's the length's ratio in we convert byte to base64 string? Is it a constant ratio or it can be different from case to case? For example if I convert a byte array...
3
by: Jimski | last post by:
Hello all, I am having a problem where I get an error message when I call FlushFinalBlock when decrypting my encrypted text. I am using the Rijndael algorithm. The error message is "Length...
3
by: some one | last post by:
I have kind of wired problem, I using httpwebrequest to post form data to server , in the GetResponse stage a WebException occurred, after tracing the actual error that occurs on the server, I...
2
by: stealth_spoof | last post by:
Hi People wondering if anyone can help me with a problem I'm having I'm trying to create an array with an unspecified length, the length is based on the result i get from another task in the code...
0
by: Hannibal111111 | last post by:
I found this code on a site for doing string encryption/decryption. The string will encrypt fine, but I get this error when I try to decrypt. Any idea why? I posted the code below. The error...
6
by: davidb | last post by:
Hi, does someone know how to get the length of a 2 dimensional string array: here what i need: ---------------------------------------------------------------- char **getList(void){ char...
14
by: Richard Maher | last post by:
Hi, Can anyone please show me a regular expression (or function or other) for padding out a string to a fixed number of bytes? At the moment I've got a var initialized to N spaces, where 'N'...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.