Nested Classes

Status
Not open for further replies.

robertb_NZ

Well-known member
Joined
May 11, 2010
Messages
140
Location
Auckland, New Zealand
Programming Experience
10+
I need to map COBOL record layouts into C# (or VB) classes. COBOL record layouts may have many definition levels, and I need to be able to cope with the rule that a field name may be repeated provided that there is a way of distinguishing which field you mean with full qualification. I thought that I could do the same in C# when I found that a class can be nested within another, so I developed C# classes corresponding to input and output web service messages like this: -
C#:
namespace MyJSv.Models
{
    public class IJSPG2
    {
        public string JZ_Function { get; set; }
        public int JZ_Employee_Skip { get; set; }
        public class JZEmployee
        {
            public string EMPNO { get; set; }
...
            public string JZ_CURRENCY { get; set; }
        }
        public class ViewState
        {
            public string CheckSum_Employee { get; set; }
        }
    }
}
However I found (and this page confirmed) that I can't refer to IJSPG2.JZEMPLOYEE.EMPNO. I can solve most problems by flattening the message layout , and dealing with name ambiguity by renaming fields. I'll handle repeating groups (arrays), by keeping them as separate classes and using C# logic to put the data into an in-memory database (as in this tutorial).

Before I go down this path can somebody please confirm for me that there is no way of creating nested classes (or structures, or any other object type) that I can refer to in this way. I'd prefer not to expend a lot of effort and then find out I didn't need to :).
 
Status
Not open for further replies.
Top Bottom