473,394 Members | 1,932 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,394 software developers and data experts.

Properties vs. fields

Hi!

I've created a web service that sends an array of custom objects to the
client. My object is defined with 2 public properties. When I receive the
XML on the client and instantiate my objects these properties are apparently
fields (I don't know the difference but this is what I've read). This means
that I can't bind the array of objects to a datagrid. Is it possible to
convert the fields into properties on the client? If so could someone please
provide an example that shows how this is done?

Help is appreciated.

Morten

My class definition looks like this:

public class SiteClass
{
private string sitename;
public string Sitename
{
get
{
return sitename;
}
set
{
sitename = value;
}
}
private StringCollection hostheaders;
public StringCollection Hostheaders
{
get
{
return hostheaders;
}
set
{
hostheaders = value;
}
}
}

Nov 21 '05 #1
1 1265
Take a look at the following article by Jan Tielens. It uses CodeDom to
generate data-bindable wrappers for custom objects on the fly:

http://www.microsoft.com/belux/nl/ms...cewrapper.mspx

Regards,
Sami

"Morten" <mo**************@hotmail.com> wrote in message
news:eN*************@TK2MSFTNGP11.phx.gbl...
Hi!

I've created a web service that sends an array of custom objects to the
client. My object is defined with 2 public properties. When I receive the
XML on the client and instantiate my objects these properties are apparently fields (I don't know the difference but this is what I've read). This means that I can't bind the array of objects to a datagrid. Is it possible to
convert the fields into properties on the client? If so could someone please provide an example that shows how this is done?

Help is appreciated.

Morten

My class definition looks like this:

public class SiteClass
{
private string sitename;
public string Sitename
{
get
{
return sitename;
}
set
{
sitename = value;
}
}
private StringCollection hostheaders;
public StringCollection Hostheaders
{
get
{
return hostheaders;
}
set
{
hostheaders = value;
}
}
}

Nov 21 '05 #2

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

Similar topics

18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
15
by: Gary Morris | last post by:
Hello all, OK, first of all I have known about properties since VB6, which I have and have used extensively. It seems that property get and set are basically the same concept in C# and VB.NET,...
23
by: Marcin Grzębski | last post by:
I red MSDN article of C# 2.0 this week... and i found very strange syntax for properties e.g.: public int MyIntValue { get { // ... } protected set { // ... }
26
by: julien | last post by:
Hello, I don't know when to use fields and when to used properties. It looks to me that using properties is always better. But I guess fields must be better in some cases, otherwise they wouldn't...
7
by: Donald Grove | last post by:
Is it possible to retrieve field properties from a table in access2000 using code? I have tried: " dim dbs as dao.database dim tbl as dao.tabledef dim fld as dao.field dim prop as...
11
by: LDD | last post by:
What is the real benefit of using Properties? You can declare class variables either public/private. I'm not sure I understand the true benefit. Especially if you are reading from/writing to...
47
by: Jon Slaughter | last post by:
private string name; public string Name { get { return name; } set { name = value; } } In the above, why doesn't C# just allow one to create a single directive to make a property?
17
by: The Frog | last post by:
Hello everyone, I am working on an application that can build database objects in MS Access from text files. I suppose you could call it a backup and restore type routine. Accessing the...
19
by: pinkfloydhomer | last post by:
I can understand why properties are neat if you want to limit access (only get, no set), or you want to do some bookkeeping or sanity checking on values (in set) or if you want to change the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.