Hello,

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#)

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.

Great!
That solved my problem.
Thanks ddanbe!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.