How do you "Find" a substring in StringBuilder?

amakeler

Member
Joined
Dec 23, 2008
Messages
7
Programming Experience
10+
Hi all,

How do you Find a substring in StringBuilder?
E.g., I want it to tell me if there is substring in a string, and if so, what's its position is.

I can see a Replace member but not a Find member.

Maybe there is some way of using the Replace op also as a Find op?

TIA

- avi
 
The StringBuilder class provides functionality only for building strings, to do other common string operations extract the current string with ToString method and use the String class methods.
Regex class is also very useful for string search/replace/split operations.
 
StringBuilder

I am surprised and shocked.

Couldn't they have made the StringBuilder class more flat and provide all the functions thru the same level , e.g. StringBuilder.Find(----) ?

I have to give a presentation and I have to show how OOP makes things easier. String vs. StringBuilder is bad; it shows how everything got more complex.
 
There is no "String vs. StringBuilder", they are two altogether different objects. If you want to discuss String, then this is the only object you need to focus on, you can easily add two strings together with no knowledge of a StringBuilder.

The StringBuilder exist for building a String fast and provides convenience methods for doing this, a String is a String. When you understand what immutable means in relation to building strings you understand the need for a StringBuilder, and when you have tested it you would surely appreciate it. What is the problem calling ToString when you need to go out to String object level? Understand that it means moving from one object to a different one.
 

Latest posts

Back
Top