473,385 Members | 1,518 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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
Nov 15 '05 #1
2 3054
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" <dk*******@hotmail.com> wrote in message
news:03****************************@phx.gbl...
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

Nov 15 '05 #2
Doug <dk*******@hotmail.com> wrote:
How do I declare a class to have a parameter of a certain
type?


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
http://www.pobox.com/~skeet/csharp/constructors.html

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

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Andy | last post by:
Hi Could someone clarify for me the method parameter passing concept? As I understand it, if you pass a variable without the "ref" syntax then it gets passed as a copy. If you pass a...
7
by: Robert Lario | last post by:
For examples sake I have made up a very simple example. I have an object called foo1 which is of type foo. I want to be able to call a funtion called myfunc as follows: myfunc(ref foo1) ...
4
by: Ron Rohrssen | last post by:
I want to show a dialog and when the form (dialog) is closed, return to the calling form. The calling form should then be able to pass the child form to another object with the form as a...
7
by: Ken Allen | last post by:
I have a .net client/server application using remoting, and I cannot get the custom exception class to pass from the server to the client. The custom exception is derived from ApplicationException...
3
by: Mark | last post by:
Hi From what I understand, you can pass arrays from classic ASP to .NET using interop, but you have to change the type of the.NET parameter to object. This seems to be because classic ASP passes...
12
by: scottt | last post by:
hi, I am having a little problem passing in reference of my calling class (in my ..exe)into a DLL. Both programs are C# and what I am trying to do is pass a reference to my one class into a DLL...
3
by: Ross McLean | last post by:
Hi all, I've been teaching myself C# for a new project at work. I have a bit of a background in c++ and java but never been what you could call a guru. I'm having some strange things happening...
2
by: diffuser78 | last post by:
I wrote a small app in wxPython using wxGlade as designer tool. wxGlade brings and writes a lot of code by itself and thats where my confusion started. Its about parameter passing. Here is my...
10
by: amazon | last post by:
Our vender provided us a web service: 1xyztest.xsd file... ------------------------------------ postEvent PostEventRequest ------------------------------------- authetication authentication...
7
by: TS | last post by:
I was under the assumption that if you pass an object as a param to a method and inside that method this object is changed, the object will stay changed when returned from the method because the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.