Based on your comments, it seems you want to access items of either m_shellPathsT
or m_shellPathsS
via ShellPaths
.
So, assuming foo is an object of type PublishProperties
, you want to be able to write code like this:
foo.ShellPaths[0];
What happens here is actually two things:
- You are accessing property
ShellPaths
on type PublishProperties
. It returns a List<string>
- You are accessing the item at index
0
of the returned list. It returns a string
.
The property ShellPaths
has the following structure:
public List<string> ShellPaths
{
get { return <something>; }
}
As you can see, there is no index.
But because you want to access different lists based on the index, the implementation of ShellPaths
can't simply return either one of your internally stored lists.
You will have to create a new list that returns the first item of m_shellPathsT
if the index is 0
. Otherwise it returns the corresponding item of m_shellPathsS
.
To achieve this, you could implement ShellPaths
like this:
public List<string> ShellPaths
{
get { return m_shellPathsT.Take(1).Concat(m_shellPathsS.Skip(1)).ToList(); }
}
Now, that would work, but would be quite unefficient: Every time someone accesses ShellPaths
a new list is created. It would be better if you would create that special list once, maybe in the constructor or whenever the content of any of the internal lists changes.