Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

global vars arrays

Posted on 2008-10-12
2
808 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 240 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 260 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

856 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