Avatar of Camillia
CamilliaFlag for United States of America

asked on 

Set and Get Property for class and populating them

something strange with "set" and "get".
I get a List<customer> populated. I right click on the list and i see the Customer items. I see for example, lets take the lastname. I have:
 1.public string LastName
            {
                get { return GetValue<string>(Columns.LastName); }

                set { _lastName = value; }
            }
2. I get the dataset and do this:
List<customer> myList = new List<customer>;
Customer customerInfo = new Customer();
customerInfo.LastName = row[3].ToString();
myList.add(customerInfo);

3. After the list is populated, i look at one row. I see a value for : _lastName but LastName is null.
Same for all the properties. For example, for "id" which is a GUID ...I see _ID as having a value but ID as having all zeroes.

 Shouldnt "ID" and "_ID" both have the same value? My code looks for value in "ID" column not in "_ID" column..

--- The orig ex-developer code works and 'ID" or "LastName" properties are populated. ***Only the private members are populated...****
C#

Avatar of undefined
Last Comment
Camillia
ASKER CERTIFIED SOLUTION
Avatar of philipjonathan
philipjonathan
Flag of New Zealand image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Camillia
Camillia
Flag of United States of America image

ASKER

ah..makes sense...

But I cant change the "Get" property. I might break the ex-developer's code. This is a huge code...

>>change the set to save the value to Column.LastName
I can do that . But how? do u have an example?
Let's see, do you mind to share what is inside the function GetValue?
We would need to do the reverse of it, instead of getting, we are setting a value.
Avatar of Camillia
Camillia
Flag of United States of America image

ASKER

ah, let me step thru the code and find it. I'm new at the job and the only developer now.

Let me find it.  Will try your method and if I cant figure it out, will post it. Have to do it tomorrow .
Thanks for sticking with this. Will post back.
Kamila.
No prob, just update this question, it will automatically alert me.
Avatar of Camillia
Camillia
Flag of United States of America image

ASKER

all makes sense. Thanks for your help
C#
C#

C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).

98K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo