Click here to Skip to main content
16,007,687 members
Home / Discussions / C#
   

C#

 
GeneralRe: Convert from true type font to vector image Pin
Heath Stewart16-Mar-04 3:09
protectorHeath Stewart16-Mar-04 3:09 
QuestionC# and XSLT [ Bug ] ? Pin
Matthew Hazlett15-Mar-04 14:34
Matthew Hazlett15-Mar-04 14:34 
AnswerRe: C# and XSLT [ Bug ] ? Pin
Matthew Hazlett15-Mar-04 19:46
Matthew Hazlett15-Mar-04 19:46 
AnswerRe: C# and XSLT [ Bug ] ? Pin
Heath Stewart16-Mar-04 3:00
protectorHeath Stewart16-Mar-04 3:00 
Generaliterate through enum Pin
Christian Graus15-Mar-04 13:14
protectorChristian Graus15-Mar-04 13:14 
GeneralRe: iterate through enum Pin
Christian Graus15-Mar-04 14:34
protectorChristian Graus15-Mar-04 14:34 
GeneralForms & variables & suchlike Pin
surgeproof15-Mar-04 10:54
surgeproof15-Mar-04 10:54 
GeneralRe: Forms & variables & suchlike Pin
Judah Gabriel Himango15-Mar-04 11:07
sponsorJudah Gabriel Himango15-Mar-04 11:07 
Make the variable as public, or create a public getter property for the variable. Then just pass the Form instance to your FrmTempTools child.

public class FrmMain : Form
{
   public int myVar = 6;

   public FrmMain()
   {
      ChangeTheValue();
   }

   private void ChangeTheValue()
   {
      ChildOfFrmTempTools t = new ChildOfFrmTempTools(this); // pass this class
   
      Console.WriteLine(myVar); // outputs "12"
   }
}

public class ChildOfFrmTempTools
{
   public ChildOfFrmTempTools(FrmMain mainInstance)
   {
       mainInstance.myVar = 12;
   }
}


Also note you can use the ref or out keywords to pass the variable by reference, rather than the default of passing by value. For instance

public void Test()
{
   int i = 6;
   Modify(ref i);
   Console.WriteLine(i); // outputs 12
}

public void Modify(ref int i)
{
   i = 12;
}



---------------------------
He who knows that enough is enough will always have enough.

-Lao Tsu

GeneralRe: Forms & variables & suchlike Pin
surgeproof16-Mar-04 8:16
surgeproof16-Mar-04 8:16 
GeneralRe: Forms & variables & suchlike Pin
surgeproof17-Mar-04 6:38
surgeproof17-Mar-04 6:38 
GeneralProcessDialogKey and AppDomain Pin
zilch15-Mar-04 9:37
zilch15-Mar-04 9:37 
GeneralRe: ProcessDialogKey and AppDomain Pin
Heath Stewart15-Mar-04 9:55
protectorHeath Stewart15-Mar-04 9:55 
GeneralRe: ProcessDialogKey and AppDomain Pin
Nemanja Trifunovic15-Mar-04 10:23
Nemanja Trifunovic15-Mar-04 10:23 
GeneralRe: ProcessDialogKey and AppDomain Pin
Heath Stewart15-Mar-04 10:50
protectorHeath Stewart15-Mar-04 10:50 
GeneralRe: ProcessDialogKey and AppDomain Pin
zilch15-Mar-04 10:34
zilch15-Mar-04 10:34 
GeneralRe: ProcessDialogKey and AppDomain Pin
Heath Stewart15-Mar-04 10:48
protectorHeath Stewart15-Mar-04 10:48 
GeneralRe: ProcessDialogKey and AppDomain Pin
zilch15-Mar-04 11:12
zilch15-Mar-04 11:12 
GeneralRe: ProcessDialogKey and AppDomain Pin
Heath Stewart15-Mar-04 11:27
protectorHeath Stewart15-Mar-04 11:27 
GeneralRe: ProcessDialogKey and AppDomain Pin
zilch15-Mar-04 12:43
zilch15-Mar-04 12:43 
GeneralRe: ProcessDialogKey and AppDomain Pin
zilch15-Mar-04 13:09
zilch15-Mar-04 13:09 
QuestionRe: ProcessDialogKey and AppDomain Pin
gratajik31-Jan-11 13:38
gratajik31-Jan-11 13:38 
GeneralTask Bar Pin
SherKar15-Mar-04 7:40
SherKar15-Mar-04 7:40 
GeneralRe: Task Bar Pin
Judah Gabriel Himango15-Mar-04 9:12
sponsorJudah Gabriel Himango15-Mar-04 9:12 
GeneralRe: Task Bar Pin
Stefan Troschuetz15-Mar-04 9:51
Stefan Troschuetz15-Mar-04 9:51 
GeneralRe: Task Bar Pin
Heath Stewart15-Mar-04 10:01
protectorHeath Stewart15-Mar-04 10:01 

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.