How to access a variable (string array) in another method within the same class, but not using global variables? C # WinForms
1 answer
If an array is declared inside a single method and the link to it is not stored anywhere outside this method, then it is impossible to access it. You must store a reference to this array in a field or property of the current or some other class.
UPD: the simplest example
using System.Windows.Forms; namespace ass { public partial class Form1 : Form { private int[] _массив; void Фуу() { _массив = new[] {666, 13}; } void Бар() { _массив[1] = 12; } public Form1() { InitializeComponent(); Фуу(); Бар(); } } } - Thank. Can you give an example of how this is done? - Dmitry Shulga
- one@DmitryShulga has already written to you in the comments DreamChild. Read books on OOP in your language. - Vladimir Martyanov
|