Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 3 years ago.
Improve this question
hi friends i already finished the multiplication part of this.but i cant insert this "[]" to the numbers like in the above picture anyone can help me to do this using C#.
Without any your code to display data, I can't help you in fact.
So, I suppose, if you convert your numbers into strings or use string.Format (or string interpolation $""), you can add any characters. In a picture I see secondary diagonal matrix.
So, this is example of code, to display data like in a picture
int diag = 9;
for (int i = 1; i < 10; i++)
{
Console.Write($"{i}\t");
for (int j = 2; j < 10; j++)
{
if (diag != j)
Console.Write($"{j * i}\t");
else
Console.Write($"[{j * i}]\t");
}
diag--;
Console.WriteLine();
}
Related
Closed. This question needs debugging details. It is not currently accepting answers.
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.
Closed 5 years ago.
Improve this question
Quick question:
I am writing in unity c#, and have an array containing several instances of the same object. I want to change a non-static bool in every member of the array, and set it to true. How would I do this?
I have played around with for-loops, and searched both here and at the unity forums, but cannot find an answer. I don't believe my messy, faulty code would be of any help. Anybody care to enlighten me? :)
EDIT: Thanks for the tips, will try them now. The code was asked for, excuse the mess:
Component[] toMerge;
for (int t = 0; t < mergeTargets.Length; i++) {
toMerge[t] = mergeTargets[t].gameObject.GetComponent<Enemy>();
toMerge.readyToMerge = true;
}
for (int t = 0; t < toMerge.Length; t++) {
toMerge[t].readyToMerge = true;
}
You have to allocate mergeTargets.Length items in toMerge array and address not the array but its item:
//DONE: We need mergeTargets.Length items in toMerge
Component[] toMerge = new Component[mergeTargets.Length];
for (int t = 0; t < mergeTargets.Length; i++) {
toMerge[t] = mergeTargets[t].gameObject.GetComponent<Enemy>();
//DONE: [t] - we want to change item, not the array
toMerge[t].readyToMerge = true;
}
Closed. This question needs debugging details. It is not currently accepting answers.
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.
Closed 6 years ago.
Improve this question
I want to export the excel sheet but lblvess is contain multiplce value show it is not export the excel sheet.it can print only single value how can show all value of lblvess.where ws.Cell("A5").Value = lblvess is export only single value
Code:-
for (int j = 0; j < gvvessel.Rows.Count; j++)
{
Label lblvess =(Label)gvvessel.Rows[j].FindControl("lblvesselName");
ws.Cell("A5").Value = lblvess;
}
for (int j = 0; j < gvvessel.Rows.Count; j++)
{
int index=5;
Label lblvess =(Label)gvvessel.Rows[j].FindControl("lblvesselName");
ws.Cell("A"+index.ToString()).Value = lblvess.Text;
index++;
}
Closed. This question needs debugging details. It is not currently accepting answers.
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.
Closed 8 years ago.
Improve this question
hi I need to write each element of an array in a line of a textbox
I have tried this code my array is taken from an input file also the number of element of the array
string[] myArray = values[(int)TextBoxIndices.idcourses].Split('-');
string[] tempArray = new string[Int32.Parse(values[(int)TextBoxIndices.totalnbre])];
tempArray = idc.Lines;
for (int t = 0; t < Int32.Parse(values[(int)TextBoxIndices.totalnbre]); t++)
{
tempArray = myArray[t] + '\n';
}
Your for loop is using a value taken from your values array as the count limit, but you are indexing myArray. As you stated in your comment, you are going outside your array bounds.
You should have:
for (int t = 0; t < myArray.Length; t++)
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 don't understand how to do this im new to programming but im sure its simple. help the code I have so far is:
I need the asterisks to be separating the numbers
for (int i = 0; i < 101; i++)
Console.WriteLine(i);
Console.WriteLine("********");
but the asterisks is only showing at the bottom
You should put the body of the loop into a scope:
for (int i = 0; i < 101; i++)
{
Console.WriteLine(i);
Console.WriteLine("********");
}
Otherwise only the following next command is interpreted as the body of the loop, equivalent to this:
for (int i = 0; i < 101; i++)
{
Console.WriteLine(i);
}
Console.WriteLine("********");
The way you have it is only doing the for loop on the first line. You need to put both lines into a 'block' using curly braces:
for (int i = 0; i < 101; i++)
{
Console.WriteLine(i);
Console.WriteLine("********");
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
What I try to do, is for example if I write five numbers 1,2,3,4,5 after this it should print 5,4,3,2,1
int[] numbers = new int[5];
for (int i = 0; i < numbers.Length ; i++)
{
Console.Write("");
numbers[i] = int.Parse(Console.ReadLine());
}
for (int i = 0; i < numbers.Length; i++)
{
}
If you need just to print them in a reverse order, but you want to keep them stored as you inserted them, change the second loop like this:
for (int i=numbers.Length-1; i >= 0; i--){
Console.WriteLine(numbers[i]);
}
You can print the array with a reverse loop as in the previous answer, or you can do that in a single line:
Console.WriteLine(string.Join(",", numbers.Reverse()));