aronmatthew
Well-known member
- Joined
- Aug 5, 2019
- Messages
- 80
- Programming Experience
- Beginner
for some reason I cant view properties while debugging using sub class with base class List
using listWrapper.a.a;
namespace listWrapper.La1.La1
{
public class _La1 : List<_a>
{
private string field;
public string Property
{
get { return field; }
set { field = value; }
}
public _La1()
{
Property = default(string);
}
public _La1(_La1 rh)
{
}
}
}
using System.Collections;
using listWrapper.a.LEa;
using listWrapper.a.La;
using listWrapper.a.a;
using listWrapper.La1.La1;
namespace listWrapper.a.LWa
{
public class DLWa
{
public static void driver()
{
//cannot see properties contained in sub class while debugging
_La1 aListInherited = new _La1();
_LWa aListWrapper = new _LWa();
int i;
for (i = 0; i < 3; i++)
{
_a a = new _a();
aListWrapper.List.Add(a);
}
i = 0;
foreach (_a a in aListWrapper)
{
aListWrapper[i].Id = aListWrapper.List.nextId("a", 3);
i++;
}
}
}
}
Property
that is part of your class that inherits from List<T>
without requiring extra clicks. Visual Studio is trying to be helpful in thinking that most people don't need to see the internal implementation of a List<T>
class because most people have moved on to the follow the object oriented design principle of "composition over inheritance".using System.Collections;
using listWrapper.a.LEa;
using listWrapper.a.La;
using listWrapper.a.a;
namespace listWrapper.a.LWa
{
public class _LWa : ALWa, Ia, IComparable, IEquatable<_LWa>,IEnumerable
{
public _LWa()
{
List = new _La();
}
public _LWa(_LWa rh)
{
List = new _La(rh.List);
}
public bool Equals(_LWa rh)
{
throw new NotImplementedException();
}
public int CompareTo(object obj)
{
if (obj == null) return 1;
_LWa _obj = obj as _LWa;
if (_obj != null)
return compare(this, _obj);
else throw new ArgumentException("obj is not a baseClass in baseClass compareTo");
}
public static int compare(_LWa lh, _LWa rh)
{
throw new NotImplementedException();
}
public void write(StreamWriter sw)
{
throw new NotImplementedException();
}
public bool read(StreamReader sr)
{
throw new NotImplementedException();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public _LEa GetEnumerator()
{
return new _LEa(List);
}
}
}
using System.Collections;
using listWrapper.a.LEa;
using listWrapper.a.La;
using listWrapper.a.a;
namespace listWrapper.a.LWa
{
public abstract class ALWa
{
private _La list;
public _La List
{
get { return list; }
set { list = value; }
}
public int Count
{ get { return List.Count; } }
public _a this[int key]
{
get { return List[key]; }
set { List[key] = value; }
}
}
}
using System.Collections;
using listWrapper.a.LEa;
using listWrapper.a.La;
using listWrapper.a.a;
namespace listWrapper.a.LWa
{
internal interface Ia
{
public bool Equals(_LWa rh);
public bool read(StreamReader sr);
public int CompareTo(object obj);
public void write(StreamWriter sw);
}
}
using System.Collections;
using listWrapper.a.a;
namespace listWrapper.a.La
{
public class _La : List<_a>, ILa, IEnumerable
{
public int n;
public _La() : base() { }
public _La(_La rh) : base(rh) { }
public _a this[int key]{get => getValue(key);set => setValue(key, value);}
private string generateId(string prefix, int length)
{
Random rnd = new Random();
string id = prefix;
for (int i = 0; i < length; i++)
id += rnd.Next(0, 10);
return id;
}
public string nextId(string prefix, int length)
{
bool flag;
string id;
do
{
flag = false;
id = generateId(prefix, length);
foreach (_a a in this)
{
if (a.Id == id)
{
flag = true;
break;
}
}
} while (flag);
return id;
}
public _a getValue(int index)
{
try
{
if (index < 0 || index >= Count)
throw new IndexOutOfRangeException("index out of range in list getValue");
return base[index];
}
catch (Exception ex)
{
return null;
}
}
private void setValue(int index, _a value)
{
try
{
if (index < 0 || index >= Count)
throw new IndexOutOfRangeException("index out of range in list setValue");
base[index] = value;
}
catch (Exception ex)
{
}
}
public void write(StreamWriter sw)
{
foreach (_a obj in this)
obj.write(sw);
}
public void read(StreamReader sr)
{
_a obj = new _a();
while (obj.read(sr) == true)
{
Add(obj);
obj = new _a();
}
}
//list.sort((x, y) => x.Value.CompareTo(y.Value));
}
}
n
member that is part of your _La
class unless the "Raw View" is expanded: