Click here to Skip to main content
15,888,454 members
Home / Discussions / C#
   

C#

 
GeneralRe: Forms Question Pin
Kannan Kalyanaraman23-Feb-03 15:53
Kannan Kalyanaraman23-Feb-03 15:53 
GeneralRe: Forms Question Pin
James T. Johnson23-Feb-03 16:07
James T. Johnson23-Feb-03 16:07 
GeneralRe: Forms Question Pin
gekoscan23-Feb-03 17:05
gekoscan23-Feb-03 17:05 
Questionhow to get an object's values from other form ? Pin
pkBob23-Feb-03 13:34
pkBob23-Feb-03 13:34 
AnswerRe: how to get an object's values from other form ? Pin
draco_iii23-Feb-03 14:45
draco_iii23-Feb-03 14:45 
GeneralDataGrid and ReadOnly column Pin
Nish Nishant23-Feb-03 13:16
sitebuilderNish Nishant23-Feb-03 13:16 
GeneralRe: DataGrid and ReadOnly column Pin
James T. Johnson23-Feb-03 15:32
James T. Johnson23-Feb-03 15:32 
GeneralReferencing string member vars Pin
moredip23-Feb-03 6:25
moredip23-Feb-03 6:25 
Hi all,

I've got a class that holds lots of different public string members:
public class AuthorData
{
  public string Name;
  public string Addr1;
  public string Addr2;
  //etc.
  //...
  //...
}
I'd like to be able to add references to these strings to a member string[] variable, so that I can perform operations on all of them at once with a foreach loop:
public class AuthorData
{
  public string Name;
  public string Addr1;
  public string Addr2;
  //etc.
  //...
  public string[] allStringMembers;
  //...
}
Problem is, I can't figure out how to construct the array so that it references the string variables, rather than a copy of them. All of my attempts so far lead to an array where changes to the array contents /don't/ affect the original string members. What I need is the equivelant of a 'pointer' to the string members, but I can't figure out how to get one. I've tried messing around with String::Clone(), and String.Intern(), but can't seem to get a reference.

As a side-issue, it would be nice to add another layer of indirection to the array (in effect an array of pointers to pointers to the string members), as this would allow me to initialise the array in AuthorData's constructor. A single layer of indirection wouldn't allow this, as the string[] would simply contain null's - the member string vars are assigned null initially. If I can't do this, I think I'd have to make allStringMembers a readonly property that dynamically creates the array every time it is accessed.

I hope that all makes sense, if examples of my (failed) attempts would be helpful, please say so.

TIA,

Pete
GeneralRe: Referencing string member vars Pin
Jim Stewart23-Feb-03 7:13
Jim Stewart23-Feb-03 7:13 
GeneralRe: Referencing string member vars Pin
moredip23-Feb-03 7:23
moredip23-Feb-03 7:23 
GeneralRe: Referencing string member vars Pin
Jim Stewart23-Feb-03 7:28
Jim Stewart23-Feb-03 7:28 
GeneralRe: Referencing string member vars Pin
moredip23-Feb-03 7:32
moredip23-Feb-03 7:32 
GeneralRe: Referencing string member vars Pin
moredip23-Feb-03 7:28
moredip23-Feb-03 7:28 
GeneralRe: Referencing string member vars Pin
moredip23-Feb-03 7:40
moredip23-Feb-03 7:40 
GeneralRe: Referencing string member vars Pin
leppie23-Feb-03 7:34
leppie23-Feb-03 7:34 
GeneralRe: Referencing string member vars Pin
moredip23-Feb-03 7:36
moredip23-Feb-03 7:36 
GeneralRe: Referencing string member vars Pin
leppie23-Feb-03 9:32
leppie23-Feb-03 9:32 
GeneralRe: Referencing string member vars Pin
moredip23-Feb-03 11:12
moredip23-Feb-03 11:12 
GeneralRe: Referencing string member vars Pin
leppie23-Feb-03 11:26
leppie23-Feb-03 11:26 
GeneralRe: Referencing string member vars Pin
moredip23-Feb-03 11:32
moredip23-Feb-03 11:32 
GeneralHelp with creating a C# web service Pin
Manster23-Feb-03 4:17
Manster23-Feb-03 4:17 
GeneralRe: Help with creating a C# web service Pin
Kannan Kalyanaraman23-Feb-03 5:39
Kannan Kalyanaraman23-Feb-03 5:39 
GeneralStart Menu Shortcuts in C# Pin
CyberKewl23-Feb-03 3:47
CyberKewl23-Feb-03 3:47 
GeneralRe: Start Menu Shortcuts in C# Pin
Stephane Rodriguez.23-Feb-03 7:10
Stephane Rodriguez.23-Feb-03 7:10 
GeneralRe: Start Menu Shortcuts in C# Pin
CyberKewl23-Feb-03 13:23
CyberKewl23-Feb-03 13:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.