473,406 Members | 2,293 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,406 software developers and data experts.

Class method doesn't seem to work

I have a class:
*******************************************
public class DecimalType
{
private decimal first = 0; //original data
private decimal data = 0; //current data
public bool nullFirst = false; //original Data null
public bool nullData = false; //current data null

public DecimalType()
{
}

public DecimalType(decimal initial)
{
first = initial;
data = initial;
}

public bool IsNull()
{
return nullData;
}

public bool IsFirstNull()
{
return nullFirst;
}

public void SetNull()
{
nullData = true;
data = 0;
}

public void SetFirstNull()
{
nullFirst = true;
first = 0;
}

// Properties

public decimal First
{
get { return first; }
set { first = value; }
}

public decimal Data
{
get { return data; }
set { data = value; nullData = false; }
}
} // end Class

********************************************

In another program I call the SetNull() method, but it isn't setting my
flag. If I directly set it, it works fine:

public static void GetValueFromDbObject(object dbObjectValue, ref
DecimalType destination)
....
destination.SetNull();
destination.Data = 2000;
destination.nullData = true;
....

If I comment out the direct change (destination.nullData), nullData is still
false. But above it is setting it to true. If I leave the
destination.nullData = true line in, the flag gets set.

Why doesn't the SetNull() method work?

Thanks,

Tom
Nov 17 '05 #1
2 1070
Because your Data property is setting it to false.

Yosh

"tshad" <ts**********@ftsolutions.com> wrote in message
news:OI**************@tk2msftngp13.phx.gbl...
I have a class:
*******************************************
public class DecimalType
{
private decimal first = 0; //original data
private decimal data = 0; //current data
public bool nullFirst = false; //original Data null
public bool nullData = false; //current data null

public DecimalType()
{
}

public DecimalType(decimal initial)
{
first = initial;
data = initial;
}

public bool IsNull()
{
return nullData;
}

public bool IsFirstNull()
{
return nullFirst;
}

public void SetNull()
{
nullData = true;
data = 0;
}

public void SetFirstNull()
{
nullFirst = true;
first = 0;
}

// Properties

public decimal First
{
get { return first; }
set { first = value; }
}

public decimal Data
{
get { return data; }
set { data = value; nullData = false; }
}
} // end Class

********************************************

In another program I call the SetNull() method, but it isn't setting my
flag. If I directly set it, it works fine:

public static void GetValueFromDbObject(object dbObjectValue, ref
DecimalType destination)
...
destination.SetNull();
destination.Data = 2000;
destination.nullData = true;
...

If I comment out the direct change (destination.nullData), nullData is
still false. But above it is setting it to true. If I leave the
destination.nullData = true line in, the flag gets set.

Why doesn't the SetNull() method work?

Thanks,

Tom

Nov 17 '05 #2
"Yosh" <yo***@nospam.com> wrote in message
news:Oa**************@TK2MSFTNGP12.phx.gbl...
Because your Data property is setting it to false.
Hence the reason for not putting multiple statements on one line.

I was looking at this over and over and assumed I was somehow setting it
back to false, but couldn't find it.

I actually want it to work that way, but I had put a test in just to see at
what point of the code I was for different types of tests and had forgotten
that when I set the propert to some value, I obviously want the Null to be
false as it isn't null anymore. The "destination.Data = 2000" was setting
to false, as you said.

Thanks,

Tom

Yosh

"tshad" <ts**********@ftsolutions.com> wrote in message
news:OI**************@tk2msftngp13.phx.gbl...
I have a class:
*******************************************
public class DecimalType
{
private decimal first = 0; //original data
private decimal data = 0; //current data
public bool nullFirst = false; //original Data null
public bool nullData = false; //current data null

public DecimalType()
{
}

public DecimalType(decimal initial)
{
first = initial;
data = initial;
}

public bool IsNull()
{
return nullData;
}

public bool IsFirstNull()
{
return nullFirst;
}

public void SetNull()
{
nullData = true;
data = 0;
}

public void SetFirstNull()
{
nullFirst = true;
first = 0;
}

// Properties

public decimal First
{
get { return first; }
set { first = value; }
}

public decimal Data
{
get { return data; }
set { data = value; nullData = false; }
}
} // end Class

********************************************

In another program I call the SetNull() method, but it isn't setting my
flag. If I directly set it, it works fine:

public static void GetValueFromDbObject(object dbObjectValue, ref
DecimalType destination)
...
destination.SetNull();
destination.Data = 2000;
destination.nullData = true;
...

If I comment out the direct change (destination.nullData), nullData is
still false. But above it is setting it to true. If I leave the
destination.nullData = true line in, the flag gets set.

Why doesn't the SetNull() method work?

Thanks,

Tom


Nov 17 '05 #3

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

Similar topics

4
by: Typpo | last post by:
Hi, This question is somewhat basic. Is it possible to call a method in frmMain, using another class? Here's a snippet: partial class frmMain : Form { private void MessageThis(String text)...
28
by: kfrost | last post by:
I know this is probably simple but I have a C# form and the class for the form is called sbaSynch. I have a textbox name txtServerName. I'm creating a class to manipulate XML functions so I...
8
by: tshad | last post by:
I cannot seem to get the asp:textbox to use classes. Style works fine. I am trying to set the textbox to act like a label in some instance so it doesn't have a border, readonly and the background...
10
by: steve bull | last post by:
I have a class SwatchPanel which takes Swatch as a parameter type. How can I call a static function within the Swatch class? For example the code below fails on TSwatch.Exists. How can I get the...
7
by: WXS | last post by:
Vote for this idea if you like it here: http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=5fee280d-085e-4fe2-af35-254fbbe96ee9...
9
by: sashang | last post by:
Hi I'd like to use metaclasses to dynamically generate a class based on a parameter to the objects init function. For example: class MetaThing(type): def __init__(cls, name, bases, dict,...
20
by: tshad | last post by:
Using VS 2003, I am trying to take a class that I created to create new variable types to handle nulls and track changes to standard variable types. This is for use with database variables. This...
3
by: wendallsan | last post by:
Hi All, I've stumped myself writing an app that uses Prototype and a bit of PHP. Here is what I have: I have a custom class named Default_county_init_data that, upon initialization makes...
5
by: Andy B | last post by:
I am trying to figure out how to make an object instance available for all methods of a class. I tried to do something like this: public class test { TheObject Instance = new TheObject();...
44
by: Steven D'Aprano | last post by:
I have a class which is not intended to be instantiated. Instead of using the class to creating an instance and then operate on it, I use the class directly, with classmethods. Essentially, 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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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
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...
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...

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.