Click here to Skip to main content
15,896,730 members
Home / Discussions / C#
   

C#

 
Questionbasic search using user control Pin
dsaikrishna30-Aug-07 20:02
dsaikrishna30-Aug-07 20:02 
AnswerRe: basic search using user control Pin
\laddie30-Aug-07 20:52
\laddie30-Aug-07 20:52 
GeneralRe: basic search using user control Pin
dsaikrishna30-Aug-07 20:58
dsaikrishna30-Aug-07 20:58 
GeneralRe: basic search using user control Pin
\laddie30-Aug-07 21:10
\laddie30-Aug-07 21:10 
GeneralRe: basic search using user control Pin
\laddie30-Aug-07 21:11
\laddie30-Aug-07 21:11 
GeneralRe: basic search using user control Pin
dsaikrishna30-Aug-07 21:18
dsaikrishna30-Aug-07 21:18 
QuestionNULL problem Pin
Xmen Real 30-Aug-07 19:45
professional Xmen Real 30-Aug-07 19:45 
AnswerRe: NULL problem Pin
Martin#30-Aug-07 20:01
Martin#30-Aug-07 20:01 
GeneralRe: NULL problem Pin
Xmen Real 30-Aug-07 22:53
professional Xmen Real 30-Aug-07 22:53 
AnswerRe: NULL problem Pin
V.30-Aug-07 20:31
professionalV.30-Aug-07 20:31 
AnswerRe: NULL problem Pin
girm30-Aug-07 20:39
girm30-Aug-07 20:39 
AnswerRe: NULL problem Pin
Vasudevan Deepak Kumar30-Aug-07 22:18
Vasudevan Deepak Kumar30-Aug-07 22:18 
GeneralRe: NULL problem Pin
Martin#30-Aug-07 22:22
Martin#30-Aug-07 22:22 
AnswerRe: NULL problem Pin
Syed Mujtaba Hassan31-Aug-07 1:00
Syed Mujtaba Hassan31-Aug-07 1:00 
GeneralRe: NULL problem Pin
Xmen Real 31-Aug-07 2:19
professional Xmen Real 31-Aug-07 2:19 
QuestionDLL output file naming convension Pin
George_George30-Aug-07 19:44
George_George30-Aug-07 19:44 
AnswerRe: DLL output file naming convension Pin
\laddie30-Aug-07 20:55
\laddie30-Aug-07 20:55 
GeneralRe: DLL output file naming convension Pin
George_George30-Aug-07 21:23
George_George30-Aug-07 21:23 
GeneralRe: DLL output file naming convension Pin
\laddie30-Aug-07 21:34
\laddie30-Aug-07 21:34 
GeneralRe: DLL output file naming convension Pin
George_George30-Aug-07 21:49
George_George30-Aug-07 21:49 
Questionhow to use Contains method?? Pin
Situ1430-Aug-07 18:46
Situ1430-Aug-07 18:46 
AnswerRe: how to use Contains method?? [modified] Pin
Martin#30-Aug-07 19:26
Martin#30-Aug-07 19:26 
Hello,

Other then Regex,
what you need is not implemented in the framework string class, AFAIK. (At least not in .Net 1.1)

The string class provides the IndexOfAny method, which only is able the search for chars.

But you could use a self written method!
Like this:
This method returns the startindex of the string which is found first.
public static int IndexOfAnyString(string TextToParse, string[] TextsToSearch)
{
	int index=-1;
	if(TextsToSearch!=null)
	{
		foreach(string actSearchText in TextsToSearch)
		{
			//Searchtext not null and not empty string
			if(actSearchText!=null && !actSearchText.Equals(string.Empty))
			{
				//call the string.IndexOf method
				index = TextToParse.IndexOf(actSearchText);
				if(index>=0)
				{
					//found a string;
					break;
				}
			}
		}
        }
	return index;
}

In .Net > 1.1, you could use the "Contains" method instead of "IndexOf"!

Call it like this:
string mainline = "Hello codeproject world";
int index = IndexOfAnyString(mainline, new string[] {"msdn", "codeproject ", "blablabla"});
//Will return: 6


This is just a basic implementation of the problem.

You could add some more features like:
case sensitivity (true/false)
out param string, which returns the matching string
returning an array of int index values for all search texts
.
.
.

Hope it helps!






-- modified at 1:43 Friday 31st August, 2007

All the best,

Martin

GeneralRe: how to use Contains method?? [modified] Pin
Situ1430-Aug-07 20:01
Situ1430-Aug-07 20:01 
AnswerRe: how to use Contains method?? Pin
Xmen Real 30-Aug-07 19:37
professional Xmen Real 30-Aug-07 19:37 
QuestionWiFi scanner Pin
Archyami30-Aug-07 17:24
Archyami30-Aug-07 17:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.