I think you're mixing the interface with your internal data representation. Let's assume for now that the fact that the strings are fixed-length isn't very important to the user of the class (except when you write it to file or something). You need some properties, like so:
class JonsClass { public string FirstName; public string LastName; public string MiddleName; public string FullName { get { return FirstName + " " + MiddleName + " " + LastName; } } public void Write(Stream strm) { // Write the data with the proper padding } } If you really must have fixed-length space-padded strings inside your objects, it's time to think of a FixedLengthString object that will hide the implementation details from you, allowing your interface to look like this class JonsFixedClass { public FixedLengthString FirstName; public FixedLengthString MiddleName; public FixedLengthString LastName; public FixedLengthString FullName { get { return FirstName + MiddleName + LastName; } } } Your FixedLengthString class will need to be convenient, of course. I would expect implicit castings from and to strings, a handy constructor that sets the length and obviously the + operator. Note that the above FixedLengthString example has a hidden bug waiting to happen - there's no constraint on FirstName's length because it's a public member. In your real class you'll need to fix that, obviously (use a setter that checks the length of 'value', and makes sure the length is the right one, for instance). Itay. -----Original Message----- From: Jon Rothlander [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 14, 2006 5:22 AM Subject: Data Structures in .Net? I'm working on something that is common in other languages, but something that .Net doesn't seem to support, at least it's not common enough for me to search the Internet for it or find it in any books. What I am trying to do is actually simple... Let's say that you have the following data... First Name (20) Last Name (20) Middle Name (20) Area Code (3) Delimiter2 (1) Phone_Prefix (3) Delimiter2 (1) Phone_Suffix (4) That data might look like... Jon Rothlander Gregory 123-123-1234 What I want to do is to create the following variables.... Name_First Name_Last Name_Middle Phone_AreaCode Phone_Del1 Phone_Pre Phone_Del2 Phone_Suf But I also want to create the following variables as well... Name_Full Phone_Full What I cannot figure out is how to do something like... Name_Full = "Jon Rothlander Gregory " Phone_Full = "123-123-1234" Then have the values in the other varibles get filled without having to code lots of Mid() string commands. In other lanugauges like C, RPG, COBOL, and other, you can declare a variable that points to a given set of memory. Then you can declare other variables to point that that same memory. Then when you update one variables, all the other variables that also point to that memory are automatically update as well. That's what I'm trying to do. If you could do this in .Net like you could in COBOL or RPG, you would do something like... Dim Name_Full as String Length(60) Start(1) End(60) Dim Name_First as String Length(20) Start(1) End(20) Dim Name_Last as String Length(20) Start(21) End(40) Dim Name_Middle as String Length(20) Start(41) End(60) What you are able to do here is to tell the compiler that Name_Full starts at position 1 and goes to position 60. Name_First starts at 1 and goes to 20. When you move a value into Name_First, the memory is updated and both Name_Full and Name_First are updated because they point to the same memory location. Is there something like this available in .Net? I have been told that there is, but no one has been able to provide me a sample. I know that I can go in and build a class to control this. I have done that and it works. The problem is that it's way to much work. I want to find something a little less complex. When I built a class to support this, I was able to create the variables as properties over a local property that stores the full set of data. Then each property pulls out a given Mid(x,y) value based on the definition of the variable. This does work, but it's a major pain. I have been told that .Net does support some various ways to have multiple variables point at the same memory location. Any ideas how .Net supports that? I'm not sure where to start looking. Best regards, Jon =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com <html><body><center><hr><b><font face=arial size=2>Visit the Tel Aviv Stock Exchange's Website<a href=http://www.tase.co.il> www.tase.co.il</a></b></body></html> =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com