Solved

global vars arrays

Posted on 2008-10-12
2
809 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to read text with RegEx... 2 35
Generate Unique ID in VB.NET 21 104
Visual Studio npm 1 29
Updating a single record in forEach using C#/Entity 7 26
Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

749 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