473,387 Members | 1,790 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.

Strange Behavior using string.IndexOf

Hi Guys I'm trying to use the indexof to compare if an string has some chars inside it, the strange thing is that it finds most of the chars, but the U character it didnt find ...

here is my code

for (i = 0; i < Data.Length; i++)
{
if (ss.IndexOf(Data[i]) > 0)
{
s2 = s2 + Data[i];
}
}

The ss has the follow string inside it "UNT2701458963hbgakcvzw" and
The Data has the follow string inside it "+2qmOj01eUvyGzaDcJcMaLmsjboHkY63mJAY6H/srh/R66PJM3qO1BQ4oOmx4YEX0BO0/4AKMUwNJSFPUxwnFsNWarsmqaYnbbKLx38h4IiR6KY4H8txyu9 7pSn2G0lUMDmUmJ7VLfzRENuYecUaOxgGPCobLYP3gCgt9mytF 3Mu6/lD4lZ1jiXy7KrDY41fqHST2DWlUprUARONuKTcFkdAsahbcf3x hXdhHVohS5RoMW9ijQI8qM2KErJ7m4ZBrTTE2FUBnfN/nxWU/rwleVasvx3lIPbE/aE3+rq6et95JV5F81xf7qIX7+A20N2NBupKzY+RH2XOAKcEAMU/flawoFDbvDYOj3KOaQ9Bu1+QiX5HQB9YA8q9OJ74IZsTxBJ2d/pRUyYCGzLAqsNHr/NVZetcFxSkpYevMIh+kmyYgxgGjmbDM9xHg+5E9doei8dPJ9ZV Qm7e5PrBT2EUXFzeStNZslQvYtZswPUGsqKajw+bOxP/aSJr3HQZJhqfD9FM5S5hj1SD8LAj77nD0fUUXVTqzBYwifcDPW zCpvvYBqHb9yA3M3HfPohrfdx\r\n"

Any tips why the U cannot be founded ?

Regards,
Loki
Apr 11 '09 #1
2 1580
tlhintoq
3,525 Expert 2GB
The capital U is the first character. It's index is zero.
Your 'if' condition is set for greater than zero.
Make it greater-than-or-equal to zero.
(or greater than -1)
Apr 12 '09 #2
Plater
7,872 Expert 4TB
To expand on that, when IndexOf fails to find the searched item, it returns a -1
Apr 13 '09 #3

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

Similar topics

4
by: Luc | last post by:
Hello All, It's the first time I read the following code. A few js files like the one below, but I don't know how to make them readable by a human ( me ). Is it a strange character set ? an...
9
by: sklett | last post by:
string url = http://localhost/subPath/Default.aspx; k = url.LastIndexOf("/", 0, url.Length); This throws an exception: Count must be positive and count must refer to a location within the...
5
by: Eric Goforth | last post by:
Hello, I have a generic subroutine that I pass an object and fieldname as arguments. The subroutine then uses reflection to search for the value of the fieldname. For example: 'Calling...
35
by: Cor | last post by:
Hallo, I have promised Jay B yesterday to do some tests. The subject was a string evaluation that Jon had send in. Jay B was in doubt what was better because there was a discussion in the C#...
1
by: hansolox1 | last post by:
The following program simply sets the icon of a form called form1. When I get the name of the embedded icon using GetManifestResourceNames(), I store the name in a string variable called s. The...
6
by: Joseph Geretz | last post by:
Writing an Outlook AddIn with C#. For the user interface within Outlook I'm adding matching pairs of Toolbar buttons and Menu items. All of the buttons and menu items are wired up to send events to...
2
by: Antonio | last post by:
Good morning, everyone. Here is the strange behavior: I have a datagrid (dgPIs) with paging enabled. When I click to view any page in the grid, it runs the private void lnkIPReg method,...
5
by: Wazzz | last post by:
Hi, I am using the following code to upload an image, i am able to upload the image and save in DB on Windows but the code fails somehow on Linux machine. Here is the code: String...
1
by: mad.scientist.jr | last post by:
I am working in C# ASP.NET framework 1.1 and for some reason Regex.Split isn't working as expected. When trying to split a string, Split is returning an array with the entire string in element ...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.