scott oliver

scott oliver

  • NA
  • 82
  • 14.9k

using variables from another class

Nov 9 2020 3:36 PM
Hello all, I am having some problems. I cannot recall how to use a variable from another method in the same class. I have a basic form at this point and I am trying to set up a progress bar. I have 3 classes the form.cs, otcFetch.cs, and  progress.cs. 
 
In otcFetch.cs I am using rest sharp to go out and download a csv file and it inserts it into a sqlLite database.Here it is taking the csv file and seperating it for insertion.
  1. string[] strSeparators = new string[] { "\r\n" };  
  2. string[] Lines = response.Content.Split(strSeparators, StringSplitOptions.None);  
  3. string[] Fields;  
  4. //update console  
  5. Console.WriteLine("Updating Database!");  
  6. //set value from number of lines in csv  
  7. int numLines = Lines.Length;  
It is inside this 
  1. public void otcRestClient()  { }  
I want to use the numLines value in another method in the same class. This variable will update my progress bar based on the number of lines in the CSV file. It will not allow me to use it though and not sure why. Any advise would be appreciated.
  1. public class Variables  
  2. {  
  3.    public static int taskSize = otcFetch.Variables.THE VARIABLE WILL NOT LIST HERE???;  
  4.       
  5.     public static int totalSize  
  6.     {  
  7.         get { return taskSize; }  
  8.         set { taskSize = value; }  
  9.   
  10.     }  
  11. }

Answers (2)