Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 1st, 2012  |  syntax: None  |  size: 0.90 KB  |  hits: 5  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Referencing non-static fields from static functions and vice versa impossible?
  2. private static int getControlHeightToUse() {
  3.   return (dynamicPanel.Height / NUMBER_OF_ROWS);
  4. }
  5.        
  6. private int getControlHeightToUse() {
  7.   return (dynamicPanel.Height / NUMBER_OF_ROWS);
  8. }
  9.        
  10. public partial class CRLoginsMainForm : Form {
  11.  
  12.   int controlHeight = getControlHeightToUse(); // <-- err
  13.        
  14. private static int getControlHeightToUse(Panel thePanel)
  15. {
  16.   return (thePanel.Height / NUMBER_OF_ROWS);
  17. }
  18.        
  19. public partial class CRLoginsMainForm : Form {
  20.  
  21.   int controlHeight = getControlHeightToUse(dynamicPanel);
  22.        
  23. private static int getControlHeightToUse(Panel panel) {
  24.   return (panel.Height / NUMBER_OF_ROWS);
  25. }
  26.        
  27. public class Foo
  28. {
  29.     // public method
  30.     public void Method1()
  31.     {
  32.     }
  33.  
  34.     public static void Data2()
  35.     {
  36.         // call public method from static method
  37.         new Foo().Method1();
  38.  
  39.     }
  40. }