I want to search for a given char sequence in a string.
For example:
I have these strings: "xpto1", "asdxpto123"

If the input is "xpto", the method I called "search" should have at its ouput a list with the strings that matched the input "xpto". In this case, both strings will be the input because both have the "xpto" char sequence.

So, I have to compare "xpto" with parts of other strings but I dont know how.
Is there anything in C# that could help me in this task?

In the code I have, the problem seems to be:

aux_string[j] = component_list[i].name[l];

"Property or indexer 'string.this[int]' cannot be assigned to -- it is read only"
(the basis I have are in C language, Im getting started in C#)

8 Years
Discussion Span
Last Post by msr

In C# strings are immutable, this may seem strange at first, especially if you come from C. Get used to it.
The way to go in C# is:

string s = "asdxpto123";
string lookupStr = "xpto";
bool test;
test = s.Contains(lookupStr);

In this case the boolean test will be true. So you can put the string s in your list.Hope it helps.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.