hi,
i am a newbie in C#. I am having a variable named stone inside a private function named rock. a variable stone is defined in a structure called sand and is accessed only as sand.stone inside the function rock. Now, I must access this variable called stone in another function...how can it be done...please help me guys.

Edited 6 Years Ago by sidhu51: n/a

class Sample{
     Sand sand=new Sand();
     void method1() { sand.stone ...... }
     void method2() { sand.stone ...... }
     .....
 }

thanks. now i am able to access the variable inside every function. btw how can the variable stone inside the private function rock be accessed in another function hill...

here s the code:

private void ExtractAnchor(string[] line, List<Anchor> SLTPAnchors, int i)
{
Anchor a;
 a.Version = line[i + 2].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1];
}

I want to access this a.Version inside another function called

private void fetchButton_Click(object sender, EventArgs e)

and anchor is the structure name defined as

struct Anchor
    {
       public string Version;
    }

Edited 6 Years Ago by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

Anchor a;
 private void ExtractAnchor(string[] line, List<Anchor> SLTPAnchors, int i)
{

 a.Version = line[i + 2].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1];
}

how can the variable named a.Version be returned from the function private void ExtractAnchor() and used in private void fetchButton_Click()???

Edited 6 Years Ago by sidhu51: n/a

This article has been dead for over six months. Start a new discussion instead.