473,386 Members | 1,830 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,386 software developers and data experts.

[C#] How can I check if an array index is valid?

Well I have a string with a couple of words.
"Blah hello smart"
They get divided up into an array like so:
[0] = "Blah"
[1] = "hello"
[2] = "smart"

Now if the string is only "Blah" I only get one array index
[0] = "Blah"

But I have to check if there is an value with index [1] in the array.
How can I do that?
Sience doing
Expand|Select|Wrap|Line Numbers
  1. if (array[1] == "")
  2. {
  3.  
  4. }
  5.  
or
Expand|Select|Wrap|Line Numbers
  1. if (array[1] == null)
  2. {
  3.  
  4. }
  5.  
just return an error saying there is no value in the array with index [1].

I found this page: http://msdn2.microsoft.com/en-us/library/aa628583.aspx
It's exactly what I need but there is no info about it. Not even what language it's for.
In C# array.exists means something whole different.

Can someone help me?
Jan 20 '08 #1
1 7467
weaknessforcats
9,208 Expert Mod 8TB
I am moving this to the .NET forum.
Jan 20 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Pjotr Wedersteers | last post by:
I have source information in a file, and (part of) this information comes as coordinates. A coordinate consists of a letter followed by a number, ranging from a1 to i9 I'd like to count the...
4
by: Christian Hackl | last post by:
I honestly wasn't able to find an answer for this design question using Google and Google Groups, so I apologize if it is asked too frequently :) Anyway: Let's say I have a multidimensional array...
4
by: PhilC | last post by:
Hi Folks, If I have an array holding a pair of numbers, and that pairing is unique, is there a way that I can find the array index number for that pair? Thanks, PhilC
16
by: ES Kim | last post by:
"A Book on C" explains a technique to use an arbitrary array index range. int* p = malloc(sizeof(int) * 10) - 1; This way, the allocated array can be accessed with index range 1 ~ 10, not 0 ~...
29
by: shmartonak | last post by:
For maximum portability what should the type of an array index be? Can any integer type be used safely? Or should I only use an unsigned type? Or what? If I'm using pointers to access array...
8
by: Joe Rattz | last post by:
Ok, I can't believe what I am seeing. I am sure I do this other places with no problems, but I sure can't here. I have some code that is indexing into the ItemArray in a DataSet's DataRow. I...
13
by: Eugene Rice | last post by:
I'm writing C code for an Atmel AVR micro controller. Because RAM space is extremely limited (about 500 bytes) I use char variables wherever I can. For example I use chars as array indices in...
26
by: Szabolcs Nagy | last post by:
what type can/should be used as array index? eg. can i use unsigned long? or should it be size_t? example: int sum(int *a, index_t n) { int s = 0; index_t i;
4
by: BravoFoxtrot | last post by:
Hi, I'm trying to build an index into a multi dimensional associative array. I may not know how many dimensions there are so i want to pass the array indexes as a variable. $arrayToAccess =...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.