Passing a parameter to a class

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Doug

    #1

    Passing a parameter to a class

    I have probably a simple question:

    How do I declare a class to have a parameter of a certain
    type? I want to declare frmAppointment to pass a
    parameter of DateTime so when I call it, I call do this:

    frmAppointment( dateTime)

    example declaration:

    public class frmAppointment : System.Windows. Forms.Form

    Thanks,
    Doug
  • Mahesh Subramanian

    #2
    Re: Passing a parameter to a class

    Use a constructor to do this.

    public class frmAppointment : System.Windows. Forms.Form

    {

    DateTime mydatetime;


    //default constructor

    public frmAppointment( )

    {

    }

    //constructor with arguments

    public frmAppointment( DateTime dt)

    {

    this.mydatetime = dt;

    }

    }

    "Doug" <dkhandler@hotm ail.com> wrote in message
    news:03ee01c350 90$3f1b43d0$a40 1280a@phx.gbl.. .[color=blue]
    > I have probably a simple question:
    >
    > How do I declare a class to have a parameter of a certain
    > type? I want to declare frmAppointment to pass a
    > parameter of DateTime so when I call it, I call do this:
    >
    > frmAppointment( dateTime)
    >
    > example declaration:
    >
    > public class frmAppointment : System.Windows. Forms.Form
    >
    > Thanks,
    > Doug[/color]


    Comment

    • Jon Skeet

      #3
      Re: Passing a parameter to a class

      Doug <dkhandler@hotm ail.com> wrote:[color=blue]
      > How do I declare a class to have a parameter of a certain
      > type?[/color]

      Classes don't have parameters, nor do you call classes. You call
      methods and constructors (and effectively properties). You might have
      meant a constructor, in which case see the other post in this thread
      and read
      Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.


      If that doesn't answer your question, give a bit more detail and I'll
      see if I can help you further.

      --
      Jon Skeet - <skeet@pobox.co m>
      Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

      If replying to the group, please do not mail me too

      Comment

      Working...