I am developing a windows application in C#. I have a button that creates an array when pressed. How do I make it so I can use the created array in another function of the same program?
How do I turn variable created in function global so I can access in another function
Collapse
X
-
That would have to deal with the scope of the array.
You will have to post your code dealing with the array.
Please use the <CODE/> button to format the posted code.
Please clearly describe your code, what it is, what it does, and what is not doing along with any errors your receive (include both the error number and the message details).
Also, please bear in mind that Bytes is not a code writting nor a homework service. We'll help you thru the problem. -
I want to be able to use charWord[] in ANOTHER button that I have AFTER initiating it here.Code:string[] Words = new string[] { "php", "html", "cplusplus", "csharp", "java", "oracle", "mysql", "python" }; public void Start_Click(object sender, EventArgs e) { Random R = new Random(); string word = Words[R.Next(0, 7)]; char[] charWord = word.ToCharArray(); int count = charWord.Length; Label[] label = new Label[9] { label0, label1, label2, label3, label4, label5, label6, label7, label8 }; for(int j = 0 ; j < 9; j++ ) { label[j].Text = ""; } for (int i = 0; i < count; i++) { label[i].Text = charWord[i].ToString(); } }Last edited by zmbd; Dec 12 '12, 12:33 PM. Reason: [Z{Please use the <CODE/> button to format posted code/html/sql. You were asked to do so in my 1st post}]Comment
Comment