This question already has answers here:
Which is the correct C# infinite loop, for (;;) or while (true)? [closed]
(20 answers)
Closed 2 years ago.
I find empty "for(;;)" statement in someone else code, and I can't figure out why it is used like this.
try
{
for (;;)
{
It is an infinite loop, just like: while (true)
Related
This question already has answers here:
string.Replace (or other string modification) not working
(4 answers)
How to remove all white space from the beginning or end of a string?
(7 answers)
Closed 8 months ago.
This post was edited and submitted for review 8 months ago and failed to reopen the post:
Original close reason(s) were not resolved
i did something. when i go through this algorithm on a paper, it makes sense... where am i wrong? i can't use trim method because the task is to use a while loop
i know i'm kinda stupid 'cause i can't figure out this simplest task, but thank you in advance to anyone who'll explain this thing!
public static string RemoveStartSpaces(string text)
{
int i = 0;
while (char.IsWhiteSpace(text[i]))
{
i++;
text.Substring(i);
}
return text;
}
This question already has answers here:
How to write Unicode characters to the console?
(5 answers)
Closed 4 years ago.
i want to ask if is possible to add in a string the "⚠" character and make it executable in console with Console.WriteLine().
you can use this code;
System.Console.OutputEncoding = System.Text.Encoding.Unicode;
Console.WriteLine("⚠");
This question already has answers here:
Is there a way to count the number of IL instructions executed?
(5 answers)
Closed 7 years ago.
I want to mesure how much instruction are executed in method example.
int a=0;
functionTest();
a=getCountInstruction() // return the number of instruction executed until now.
Their any way to do it using Profiler or some Classes ?
You have to add increase counter when you invoke your method
static int a=0;
functionTest()
{
a++;
//your code
}
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to remove elements from an array
I have an List with a bunch of data in it. Some of the lines start with a #. I want to remove those lines.
How...?
assuming its a string List
myList.RemoveAll(x => x.BeginsWith("#"));
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
In C# is a for(;;) safe and what does it really do?
So i recently came across something ive never seen before..
for (; ; )
{
}
What is exactly happening when the feilds are left blank like that?
It's an infinite loop.
Somewhere inside there should be a break; statement, or possibly an exception thrown in order for control to pass beyond the loop.
You could also achieve the same thing (probably more obviously) by doing
while (true)
{
// do stuff
}
This is an infinite loop, almost equivalent to a while(true) loop.
The break condition is not there in between the two semicolons, therefore, it must be there somewhere in the loop body.
That's an infinite for loop.