|
Programm3r wrote: Thanks for your reply and comments but, break does not work. I have tried it without success.
works for me
string[] test = {"help","me","with","for","loops"};
foreach(string t in test)
{
Console.WriteLine(t);
if( t.Equals("for"))
break;
}
|
|
|
|
|
Programm3r wrote: if (globalFileName == compareString.Substring(1, (compareString.Length - 1)))
{
/* File was found */
return file;
}
if you mean this bit, it already does by virtue of the return keyword.
In general you can break a look by using the break keyword. For completeness you may also like to look up the continue keyword in c#
|
|
|
|
|
you can use also "goto"
short example:
string filename = "";
for(int i = 0; i < 10; i++)
{
if(i == 3)
{
filename = "path"
goto FileHasFounded;
}
}
FileHasFounded:
MessageBox.Show("file name is this: " filename);
break don't work in this case because you have two loops. and it will break only from one loop
hope it will help.
respect.
spaps
|
|
|
|
|
Shpendh wrote: you can use also "goto"
The number of valid uses of goto in a language as rich as C# is negligible. In fact I can't think of any time I've used a goto in any language in the last 10 years.
Upcoming FREE developer events:
* Developer! Developer! Developer! 6
* Developer Day Scotland
My website
|
|
|
|
|
Exactly what I was thinking.
Number of times ive used goto in c#: zero!
|
|
|
|
|
Breaking out of a couple of nested loops? (I always wanted to be able to name loops, or do a break(2); or something similar)...
You're right though - theres very very few usages of goto that are "legitimate".
|
|
|
|
|
if (usingGoto)<br />
{<br />
goto jailAndDoNotPassGo;<br />
}
|
|
|
|
|
Other than in a C# switch?
|
|
|
|
|
PIEBALDconsult wrote: Other than in a C# switch?
Nope. I don't use gotos in switch statements - although I am aware that it is one of the few valid places you might consider using them.
In fact I don't use switch statements all that often as I generally (but not always) consider them a sign of a poor design. Although I think that is just because I've seen them used badly in so many situations.
Upcoming FREE developer events:
* Developer! Developer! Developer! 6
* Developer Day Scotland
My website
|
|
|
|
|
i didn't say that "goto" is the only one choise in this solution, i wanted to help him with one of the solution, i never didn't use "goto" in my application but i have only learned about it.
but anyway sorry,
maybe this example will help,
string filename = "";
bool isFound = false;
foreach(string str in strColl)<br />
{<br />
if(!isFound)<br />
{<br />
foreach(string str2 in strColl2)<br />
{<br />
if(str2 == "founded")<br />
{<br />
filename = str2;<br />
isFound = true;<br />
break;
}<br />
}<br />
}<br />
else<br />
{<br />
break;
}<br />
}
hope this will help,
spaps
|
|
|
|
|
According to the C# 2.0 standard ISO/IEC 23270
15.9.1 The break statement
....
....
When multiple switch, while, do, for, or foreach statements are nested within each other, a break statement applies only to the innermost statement. To transfer control across multiple nesting levels, a goto statement (§15.9.3) shall be used.
So there you are, it's official, use a goto.
Is there a smiley for "light the blue touchpaper and stand well back"?
|
|
|
|
|
Hi,
We are thinking about starting a new project but are worried about the take-up of .NET Framework 3 within businesses. Is is it possible to have a WCF server application connecting to a client over Binary NetTcp to talk to a .NET Framework 1.1 / 2 client?
Thanks
|
|
|
|
|
If you mean can your WCF service be consumed by a none-WCF source then the answer is yes. WCF allows you to expose your service through a wide variety of protocols, one of which should suit your needs.
|
|
|
|
|
I made it clear that I'm using netTCP, it's my understanding that it's not possible to build a non-WCF client for protocol but I'm wondering if anyone knows a way around it.
|
|
|
|
|
How to open .tif file in VC++ MFC from file open menu?
|
|
|
|
|
This is the wrong forum for this question. Please ask this here[^].
|
|
|
|
|
Hi!!
I have some problems.
Actually I do a survillance using webcam project(using c#)
I need to use my webcam to monitor activities on somewhere
recording and connect it to server .
Webcam can use more than one & client must be a windowsservice for survillance.
this is activities that I do
client:
1.Recieve a remote from server.
2.connect to webcam & capturing using Webcam_Capture.dll.
3.send it to server using RTP.
Server:
1.Setting & Remote to client.
2.Save picture for client.
3.Show Picture.
and I have a problem now because
First in Client I use Windows Form and now I need to change this code to be a windowsservice.
This service need to capture a picture from webcam by using Webcam_capture.dll
So I create a variable From Webcam_capture.dll but this class reference System.Windows.Form.usercontrol
that must add a reference to System.Windows.Form .
How can I do for this problem??? Please Help me !!!
thanks,
PZ
|
|
|
|
|
Ok, this is just a tiny bother, but I'll ask anyway. While debugging is sometimes get status messages on my console that look like this:
The thread 0x15cc has exited with code 0 (0x0).
This is nice in itself, but since I've got a whole bunch of threads running I'd like to see what thread is done running.
I could of course use a simple Debug.WriteLine("The thread " + Thread.CurrentThread.Name + " has exited") statement to see what thread has completed.
But I'm wondering if VS2005 can't be set to automatically replace the threadnumber with the thread name I assigned it?
Standards are great! Everybody should have one!
|
|
|
|
|
AFAIK it will not be possible since the Windows kernel does not hold thread names.
Have you ever seen a utility (TaskManager/SysMonitor/SystemInformation/...) show thread names?
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Well no, but since the message does mention the thread's number I figured it should be easy for VS to display the threadname that's linked to it...
Standards are great! Everybody should have one!
|
|
|
|
|
I have 2 webforms form1.aspx and form2.aspx. on form1 i have 2 buttons EDIT and NEW and on form2 i have SAVE and UPDATE .... I want to disable UPDATE button on form2 when i click NEW buttton on form1 and similarily i want to disable SAVE button when i click EDIT button in form1 . as EDIT buttton only should enable UPDATE and NEW should enable only SAVE
please ..Its Urgent !!
|
|
|
|
|
If you are opening form2 from form1, pass a value from form1 indicating which button was pressed. In the page_load event handler, enable or disable the button depending on the value received.
"You're very clever, young man, very clever," said the old lady. "But it's turtles all the way down!"
|
|
|
|
|
hi , i need ur help i m doing asp.net 2005 using C# , so i want 2 send emails automatically from database at a particular time. so what can i do this program ..plz..tell me..
thanks 2 all..
|
|
|
|
|
Are you using SQL Server? If so, you can use SQL Server to do this automatically by setting a task to run at a certain time (SQL Server has a job manager), and using the sp_sendmail functionality of SQL Server.
|
|
|
|
|
Nice. Learn something new every day. Don't do much SQL Server stuff for a while now, out of touch.
|
|
|
|