Click here to Skip to main content
15,890,932 members
Home / Discussions / C#
   

C#

 
GeneralRe: System.String and Thread Safety Pin
Leslie Sanford13-Jun-06 13:36
Leslie Sanford13-Jun-06 13:36 
GeneralRe: System.String and Thread Safety Pin
Judah Gabriel Himango13-Jun-06 13:26
sponsorJudah Gabriel Himango13-Jun-06 13:26 
QuestionSharing source code between classes? Pin
Member 9613-Jun-06 10:39
Member 9613-Jun-06 10:39 
AnswerRe: Sharing source code between classes? Pin
gantww13-Jun-06 10:46
gantww13-Jun-06 10:46 
GeneralRe: Sharing source code between classes? Pin
Member 9613-Jun-06 11:38
Member 9613-Jun-06 11:38 
GeneralRe: Sharing source code between classes? Pin
Guffa13-Jun-06 11:50
Guffa13-Jun-06 11:50 
GeneralRe: Sharing source code between classes? Pin
Member 9613-Jun-06 12:11
Member 9613-Jun-06 12:11 
AnswerRe: Sharing source code between classes? Pin
Guffa13-Jun-06 13:50
Guffa13-Jun-06 13:50 
I see. To me it sounds like it should have been a class from the beginning, but I guess you are stuck with it...

Could you make an interface that the structs would implement to give access to the data in the struct? Then you could put the common code in a class and use it from the struct. Something like:
interface IDataAccess {
   int SomeData { get; set; }
   ...
}

public class DataHandler {
   private IDataAccess dataAccess;
   public DataHandler(IDataAccess dataAccess) { this.dataAccess = dataAccess; }
   public void DoSomething() {
      // here you can access the data through the dataAccess interface:
      this.dataAccess.SomeData = 42;
   }
}

public struct SomeStruct : IDataAccess {
   public DataHandler Handler;
   public SomeStruct() {
      Handler = new DataHandler(this);
   }
   public int SomeData { get {...} set {...} }
   ...
}



---
b { font-weight: normal; }

JokeRe: Sharing source code between classes? Pin
led mike13-Jun-06 11:04
led mike13-Jun-06 11:04 
AnswerRe: Sharing source code between classes? Pin
Ed.Poore13-Jun-06 11:27
Ed.Poore13-Jun-06 11:27 
GeneralRe: Sharing source code between classes? Pin
Member 9613-Jun-06 11:39
Member 9613-Jun-06 11:39 
GeneralRe: Sharing source code between classes? Pin
gantww13-Jun-06 12:47
gantww13-Jun-06 12:47 
GeneralRe: Sharing source code between classes? Pin
Ed.Poore14-Jun-06 3:14
Ed.Poore14-Jun-06 3:14 
AnswerRe: Sharing source code between classes? Pin
Leslie Sanford13-Jun-06 11:47
Leslie Sanford13-Jun-06 11:47 
GeneralRe: Sharing source code between classes? Pin
Mr. VB.NET13-Jun-06 12:47
Mr. VB.NET13-Jun-06 12:47 
QuestionAct like message box Pin
donkaiser13-Jun-06 10:19
donkaiser13-Jun-06 10:19 
AnswerRe: Act like message box Pin
Dan Neely13-Jun-06 10:20
Dan Neely13-Jun-06 10:20 
GeneralRe: Act like message box Pin
Elina Blank13-Jun-06 10:36
sitebuilderElina Blank13-Jun-06 10:36 
GeneralRe: Act like message box Pin
donkaiser13-Jun-06 11:04
donkaiser13-Jun-06 11:04 
AnswerRe: Act like message box Pin
Elina Blank13-Jun-06 10:35
sitebuilderElina Blank13-Jun-06 10:35 
QuestionOut of memory Pin
Nick H. Lauritsen13-Jun-06 10:18
Nick H. Lauritsen13-Jun-06 10:18 
AnswerRe: Out of memory Pin
gantww13-Jun-06 10:50
gantww13-Jun-06 10:50 
GeneralRe: Out of memory [modified] Pin
Nick H. Lauritsen14-Jun-06 8:42
Nick H. Lauritsen14-Jun-06 8:42 
QuestionWeb.config file for localhost Pin
leckey13-Jun-06 9:46
leckey13-Jun-06 9:46 
QuestionCentering text with respect to width of UserControl Pin
TheBlindWatchmaker13-Jun-06 8:25
TheBlindWatchmaker13-Jun-06 8:25 

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.