473,513 Members | 2,736 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Class, Constructor and Property - II

RP
Refer to my original post at:

http://groups.google.com/group/micro...202ff938fed637

I want to know:

(1) Is it necessary to define SET property if the constructor is
already there?

(2) When the constructor has been instantiated, I want to insert the
values in a table. Where the code to insert records must reside, in
the class itself or in the Button_Click event of Windows Form.

(3) Where I can find information about C# naming convention which is
used as a standard by developers?

Nov 8 '07 #1
3 1304
RP wrote:
Refer to my original post at:

http://groups.google.com/group/micro...202ff938fed637

I want to know:

(1) Is it necessary to define SET property if the constructor is
already there?
No. Only if you want to change the property *after* the object has been
constructed
>
(2) When the constructor has been instantiated, I want to insert the
values in a table. Where the code to insert records must reside, in
the class itself or in the Button_Click event of Windows Form.
I would not implement it inside the class, as it ties the class to a
specific purpose. however, I can't tell if the button click is a good
place to do so.
>
(3) Where I can find information about C# naming convention which is
used as a standard by developers?
http://msdn2.microsoft.com/en-us/lib...ke(vs.71).aspx

Can be enforced using FxCop. If you are using VS 2005, open the project
properties and navigate to "Code Analysis". If not, you can download the
FxCop tool.

HTH,
Andy
--
You can email me by removing the NOSPAM parts below:
xm**********@gmxNOSPAM.net
Nov 8 '07 #2
RP
I am still not following why a constructor and a property [with
GET ... SET] is used simultaneously. I noticed it in many examples. I
am new to OOP. The class which I created [see my original post] uses
both a constructor and properties. After setting values in property, I
am puzzled where to use a constructor and for what?

On Nov 8, 11:30 am, Andy Mueller <m...@privacy.netwrote:
No. Only if you want to change the property *after* the object has been
constructed
Nov 8 '07 #3
There is no requirement to have a property in a class, and there is no
correlation from a constructor to a property. A property is simply a way of
encapsulating the desire to change a value of a facet of the object.

Some things, such as binding, only work with properties and not members.

Properties can be used to mask certain pieces of code behind the scenes.
For example, if you have a property on an object of class TicTacToeCell,
called CellValue, you may desire in the property set method, to check the
board to see if it causes a "win". If you did this with members rather than
properties, it would be somewhat more difficult.

I hope this helps a little.

"RP" wrote:
I am still not following why a constructor and a property [with
GET ... SET] is used simultaneously. I noticed it in many examples. I
am new to OOP. The class which I created [see my original post] uses
both a constructor and properties. After setting values in property, I
am puzzled where to use a constructor and for what?

On Nov 8, 11:30 am, Andy Mueller <m...@privacy.netwrote:
No. Only if you want to change the property *after* the object has been
constructed

Nov 8 '07 #4

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

Similar topics

3
59215
by: Pavils Jurjans | last post by:
Hallo, Is there some decent way how to get the object class name in a string format? Currently I use this: function getClassName(obj) { if (typeof obj != "object" || obj === null) return...
3
11811
by: Kirk Marple | last post by:
Just want to see if this is 'by design' or a bug... I have a common List<T> defined in a base class, and the base class has a static property to expose this list. I wanted the derived class to...
0
3198
by: Daniel Sélen Secches | last post by:
I found a good class to do a simple FTP. Very good.... I'm posting it with the message, i hope it helps someone ============================================================== Imports...
1
2243
by: John | last post by:
Hi, Maybe someone can help me with the following: "The first task by any derived class constructor is to call it’s direct or indirect base class constructor implicitly or explicitly", reads the...
4
1533
by: Tony Johansson | last post by:
Hello! I have a class definition called MyClass see below. I create an instance of this class MyClass I also want this instance to be able to modify the test instance that exist in this...
0
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7094
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5677
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1585
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.