Click here to Skip to main content
15,887,477 members
Home / Discussions / C#
   

C#

 
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 
AnswerRe: WiFi scanner Pin
Judah Gabriel Himango30-Aug-07 17:51
sponsorJudah Gabriel Himango30-Aug-07 17:51 
GeneralRe: WiFi scanner Pin
Archyami30-Aug-07 18:21
Archyami30-Aug-07 18:21 
QuestionPixel operations on a very large image in c# Pin
safee ullah30-Aug-07 16:18
safee ullah30-Aug-07 16:18 
AnswerRe: Pixel operations on a very large image in c# Pin
Judah Gabriel Himango30-Aug-07 17:27
sponsorJudah Gabriel Himango30-Aug-07 17:27 
AnswerRe: Pixel operations on a very large image in c# Pin
ekynox30-Aug-07 19:10
ekynox30-Aug-07 19:10 
AnswerRe: Pixel operations on a very large image in c# Pin
mav.northwind30-Aug-07 19:41
mav.northwind30-Aug-07 19:41 
Questionhow to enable Real-Time Communications program to call SIP server? Pin
belindasobrielo30-Aug-07 16:08
belindasobrielo30-Aug-07 16:08 
AnswerRe: how to enable Real-Time Communications program to call SIP server? Pin
Judah Gabriel Himango30-Aug-07 17:25
sponsorJudah Gabriel Himango30-Aug-07 17:25 
GeneralRe: how to enable Real-Time Communications program to call SIP server? Pin
belindasobrielo30-Aug-07 19:54
belindasobrielo30-Aug-07 19:54 
QuestionDataSets and Adapters [modified] Pin
MAW3030-Aug-07 12:52
MAW3030-Aug-07 12:52 
AnswerRe: DataSets and Adapters Pin
Judah Gabriel Himango30-Aug-07 17:23
sponsorJudah Gabriel Himango30-Aug-07 17:23 
GeneralRe: DataSets and Adapters Pin
MAW3030-Aug-07 20:05
MAW3030-Aug-07 20:05 
GeneralRe: DataSets and Adapters Pin
Judah Gabriel Himango31-Aug-07 4:09
sponsorJudah Gabriel Himango31-Aug-07 4:09 
Questionparallel programming in c#????????? Pin
mr.mohsen30-Aug-07 12:29
mr.mohsen30-Aug-07 12:29 

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.