Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

global vars arrays

Posted on 2008-10-12
2
Medium Priority
?
814 Views
Last Modified: 2013-12-17
for example, I am taking a string and splitting it apart (using spaces as the seperator) as follows:

string[] words = inputText.Split(' ');

this is obviously a very local variable within the method.

the attach code snippet is the structure I use for setting up global singular variables (i.e. non array type)...how would I create a global, dynamic array?   so the array is visible across many classes (as many different classes are utilising that content in order to process other related scripts etc).
private static string inputText;
 
        public static string _inputText
        {
            get { return inputText; }
            set { inputText = value; }
        }

Open in new window

0
Comment
Question by:amillyard
2 Comments
 
LVL 15

Assisted Solution

by:Solar_Flare
Solar_Flare earned 960 total points
ID: 22699435
you can declare a variable as public static, then you can access it from any class in your project.

eg
        public static List<string> = new List<string>();
 
       
0
 
LVL 3

Accepted Solution

by:
trunghieubkit earned 1040 total points
ID: 22699724
Using the snippet below,

U can use it in any other classes within similar namespace

Form1.Words = "Le Trung Hieu".Split(' ');

private static string[] words;
 
public static string[] Words
{
    get
    {
        return words;
    }
    set
    {
        words = value;
    }
}

Open in new window

0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Screencast - Getting to Know the Pipeline
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question