Solved

global vars arrays

Posted on 2008-10-12
2
805 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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Normally the drop down box control found in the .Net framework tools is able to select just one data and value at a time, which is displayed on the text area.   But what if you want to have multiple values to be selected in the drop down box? As …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now