Solved

global vars arrays

Posted on 2008-10-12
2
811 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
[X]
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
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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

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…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

636 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