T
Tony Johansson
Hi
I've been searching for a solution to my problem all day now but
haven't found anything which makes me think the solution is something
obvious. Any help is appreciated.
Suppose you have three classes in separate files and two namespaces.
using Pain.Common;
namespace Test
{
public class Resource : Pain.Common.AnyCollection
{
public Resource()
{
AnyCollection testCol = new AnyCollection();
}
}
}
using Pain.Common;
namespace Test
{
public class FrmMain: System.Windows.Forms.Form
{
// Stuff
testCol.xyxyxyx // <-- This is my problem
}
}
namespace Pain
{
namespace Common
{
public class AnyCollection: CollectionBase
{
public AnyCollection()
{
}
public object this[int index]
{
get
{
return (object)List[index];
}
set
{
List[index] = value;
}
}
public int Add(object obj)
{
return List.Add(obj);
}
}
}
}
As indicated by the code I'm able to create a collection in the
Resource class but I'm not able to use it in the FrmMain class (or any
other class). It is like the system is not aware of it.
Shouldn't I be able to reference class instances from another class or
class instance if they are using the same namespace and the classes
are public?
What am I doing wrong, missing here?
/TJ
I've been searching for a solution to my problem all day now but
haven't found anything which makes me think the solution is something
obvious. Any help is appreciated.
Suppose you have three classes in separate files and two namespaces.
using Pain.Common;
namespace Test
{
public class Resource : Pain.Common.AnyCollection
{
public Resource()
{
AnyCollection testCol = new AnyCollection();
}
}
}
using Pain.Common;
namespace Test
{
public class FrmMain: System.Windows.Forms.Form
{
// Stuff
testCol.xyxyxyx // <-- This is my problem
}
}
namespace Pain
{
namespace Common
{
public class AnyCollection: CollectionBase
{
public AnyCollection()
{
}
public object this[int index]
{
get
{
return (object)List[index];
}
set
{
List[index] = value;
}
}
public int Add(object obj)
{
return List.Add(obj);
}
}
}
}
As indicated by the code I'm able to create a collection in the
Resource class but I'm not able to use it in the FrmMain class (or any
other class). It is like the system is not aware of it.
Shouldn't I be able to reference class instances from another class or
class instance if they are using the same namespace and the classes
are public?
What am I doing wrong, missing here?
/TJ