Button array C# [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 years ago.
Improve this question
I have this code
Button[] ButtonArray = { btn1, btn2, btn3 };
for (int i = 0; i >= 3; i++)
{
ButtonArray[i].Text = loadData[i];
}
What I try to do is that in the buttons btn1, btn2 and btn3 loads the data from loadData array in its text property
When running the program it doesn't load anything.

You put i >= 3 instead of i <= 3. Flip it and you should be good.

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;

Shader.Find("Standart") returns null [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 saw this question, but this solution did not help me.
In custom editor window I set Standart shader to some materials. Materials were loaded from folders in project:
List<Material> materials = new List<Material>();
string[] _matPaths = FindAssetPathsWithExtension(".mat", folderWithMaterials);
foreach (string materialPath in _matPaths)
{
Material mat = AssetDatabase.LoadAssetAtPath(materialPath, typeof(Material)) as Material;
if (mat != null) { materials.Add(mat); }
}
string filePath = "";
for (int i = 0; i < materials.Count; i++)
{
materials[i].shader = Shader.Find("Standart");
Debug.Log(materials[i].shader);
}
Graphics settings screenshot:
Debug log:
Hidden/InternalErrorShader (UnityEngine.Shader)
I'm 120% sure it's not called standarT (standard maybe?). If you wanna know what a shader's name is, you'll have to look at the source. You can grab the source for Unity's built-in shaders from the downloads section of their website.

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.

While loop for an index existing [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 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.
}

Categories

Resources