I'm getting a weird error with IndexOf. It only occurs if
the substring length is 1.
"aaa".IndexOf(" a")
for example should return 0 , ie, it should find the
first "a" in "aaa". Instead, it return 2, the last "a".
This error does not occur in
"aaaa".IndexOf( "aa")
however. Here you get the expected result of 0. In other
words, it only occurs when the substring length is 1.
But, there's more.
"aaa".IndexOf(C onvert.ToChar(" a"))
DOES return 0. So, the behaviour is fine for the overload
that handles chars, but not strings.
Is what I'm seeing here a bug, or is it something normal
and I'm just being clueless about the use of indexOf ?
thanks in advance
btw - I am running on .Net framework 1.1. 1 3342
Shukri Adams <sh*@dfu.min.dk > wrote: I'm getting a weird error with IndexOf. It only occurs if the substring length is 1.
"aaa".IndexOf(" a") for example should return 0 , ie, it should find the first "a" in "aaa". Instead, it return 2, the last "a".
No it doesn't - not on my system, anyway.
using System;
public class Test
{
static void Main()
{
Console.WriteLi ne ("aaa".IndexOf( "a"));
}
}
prints 0 on my box.
Can you see the problem with the above code? How are you running your
code?
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ben |
last post by:
Hi all,
I'm trying to figure out how how complex map, filter and reduce work
based on the following piece of code from
http://www-106.ibm.com/developerworks/linux/library/l-prog.html :
bigmuls = lambda xs,ys: filter(lambda (x,y):x*y > 25, combine(xs,ys))
combine = lambda xs,ys: map(None, xs*len(ys), dupelms(ys,len(xs)))
dupelms = lambda lst,n: reduce(lambda s,t:s+t, map(lambda l,n=n:
*n, lst))
|
by: F. Da Costa |
last post by:
Hi,
This is a strange issue I'v been staring at for half a day now.
It concerns catching keys via the onkeydown handler.
In IE5+ it works fine but in Moz 1.6 (& Firebird 0.7+) it behaves most
peculiar. The 'offensive' code is included below.
The weird thing lies in the alert box preceded by // **.
* function textboxReplaceSelect *
|
by: Robert Misiorowski |
last post by:
Hello,
I have a very perplexing (at least to me) problem that hopefully
someone can help me with. I'm making a site with a 3 column layout. In the
middle column (my fluid column) I am trying to put a table of 99% width.
When I do this the table actually extends to the right over my right column
and off the screen. After much debugging and trying of different things, I
change this line in my code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD...
|
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 obfuscation ? both ?
Firefox or IE detects no errors, so the following code is run with no
problem.
|
by: Edd Dawson |
last post by:
Hi. I have a strange problem involving the passing of command line
arguments to a C program I'm writing. I tried posting this in
comp.programming yesterday but someone kindly suggested that I'd have
better luck here. So here goes!
My program ignores any command line arguments, or at least it's
supposed to. However, when I pass any command line arguments to the
program, the behaviour of one of the functions changes mysteriously. I
have...
| |
by: JohnR |
last post by:
From reading the documentation, this should be a relatively easy thing. I
have an arraylist of custom class instances which I want to search with
an"indexof" where I'm passing an instance if the class where only the
"searched" property has a value. I expected to get the index into the
arraylist where I could then get the entire class instance. However, the
'indexof' is never calling my overloaded, overrides Equals method. Here is
the...
|
by: Chris Davoli |
last post by:
I'm using IndexOf on my strings to find if there are certain words contained
in a string. Well, this works fine except when I'm looking at an empty
string, because the return value is zero based index. With an empty string it
also returns 0, the same as it would with a string where it starts in the
first position (zero value). Is there anyting else to use to search for a
string in the .Net framework or is there a was to use IndexOf with...
|
by: Atli |
last post by:
The following small HowTo is a compilation of an original problem in getting some cookie-values through different methods of string-handling.
The original Problem was posted as follows:
As you can see, there could have been a problem with the split-method. The following short article handles ways around this possible problem, that we couldn't reproduce, but someone may possibly encounter it too sometimes. If nothing else, the shown...
|
by: Eric Layman |
last post by:
Hi everyone,
Im puzzled by a NULL behaviour in SQL 2000 server.
There is a column in the table that does not allow NULL.
During data mining, the staff noted that, for that particular column, there
are a few records that are empty.
I do not specifically know whether they are "alt + 0160" character.
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |