While loop for an index existing [closed] - c#

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 days ago.
Improve this question
How could I write a while loop that said the following (pseudo code):
While the index of "blahblah" in string 1 exists
do this

while(string1.Contains("blahblah")) {
// do this
}
Pseudocode compiled to C# successfully. 0 errors, 0 warnings. Time taken: 0:00:01.860.

var string1 = "blahblah blahblah blahblah blahblah ";
int pos = -1;
while (0 >= (pos = string1.IndexOf("blahblah", pos + 1)))
{
// do this.
}

Related

Why for loop is acting like while loop in C# Arrays? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 months ago.
Improve this question
this for loop inside arrays is working like while and printing only the second index.
what should i do to make it print only even indexes?
You have inverted the += operator in your for loop. You're saying i = +2 which is the same as i = 2
The correct code would be:
for (int i = 0; i < cars.Length; i += 2)
{
Console.WriteLine(cars[i]);
}

Syntax error "," expected but i can't find it (C# Unity) [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
private int skor 0;
it says "syntax error "," expected" and i cant figure out why i am very new at unity sorry if it has a very obvious answer.
You are missing assignment operator = in your skor declaration:
private int skor = 0;

How to check if a string contains any letter besides Z [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I am trying to check to see if this object contains any letters besides Z and if it does it should return Null. The way I have it initialized gives me no errors but when testing it does not actually return null if a letter is present.
if(request.DoorTag.Contains(#"[a - yA - Y]"))
{
return null;
}
if(Regex.IsMatch(request.DoorTag, "[a-yA-Y]")
{
return null;
}
But "[^zZ]" would even be better, since it'll check that your DoorTag contains any other char than Z

IEnumerable<T> Queue.Count is not returning an integer [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 4 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I am attempting to define a queue named movingAverages with a size of queue.Count - period. I am getting an error "int IEnumerable.Count() ... - cannot be applied to method and int....
private static IEnumerable<DateClose> MovingAverage(
IEnumerable<DateClose> queue, int period)
{
Queue<DateClose> movingAverages = new Queue<DateClose>(queue.Count + period);
return movingAverages;
}
Well it's because IEnumerable<T>.Count is a method, so you are missing the parentheses at queue.Count + period, which should be queue.Count() + period.

Increment label by 20 each button click [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
How can I Increment a label by 20 each time I click a button I've tried with this code:
private int sjokolade = 0; (outside of void)
sjokolade = +20;
this.metroTile1.TileCount = 1;
label1.Text = (+sjokolade).ToString();
Thanks!
You want to use += and not =+ since the first is a shorthand for sjokolade= sjokolade+20 and the second is setting it equal to positive 20.

Categories

Resources