The function works well.
If add dynamical value located to other class, and i still want to declare the list0 at Main(). How to ?
Thank you.
using System;
using System.Collections.Generic;
using System.Text;
class Program
{
public static void Main()
{
List<string> list0 = new List<string>();
list0.Add("A"); // Move to other class.
list0.Add("B"); // Move to other class.
string line0 = string.Join("/", list0.ToArray());
Console.WriteLine(line0);
Console.ReadLine();
}
}
======================================
UPDATED.
With your help. My problem soluted. a further more question below.
using System;
using System.Collections.Generic;
using System.Text;
public class Program
{
public static void Main()
{
List<string> list0 = new List<string>();
list0.Add("A");
list0.Add("B");
otherClass oAdd = new otherClass();
oAdd.AddItem(list0);
string line0 = string.Join("/", list0.ToArray());
Console.WriteLine(line0);
Console.ReadLine();
}
}
public class otherClass
{
//error CS0117: 'otherClass' does not contain a definition for 'AddItem'
// If uncommented and switch to this line show the error above. I don't know why?
//public static void AddItems(IList<string> list0)
public void AddItem(IList<string> list0)
{
list0.Add("C");
list0.Add("D");
}
}
I found another problem. thanks.