G
Greg Merideth
While I can't post all of the code I'll post snippets but, it appears that C#
is *not* assigning a string, inside of a class, a value that I am passing to it
using its public set method and I can't for the life of me figure out why.
I have a class, call it Class Test with a private string _a and a public member
string a with a get{ return value; } set{ _a = value; }
I have a method, call it MyMethod() that returns a string
If I create Test mytest = new Test()
and then
mytest.a = MyMethod()
a is *not* assigned the value coming from the method function..now...here's the
kick in the pants.
I've debugged this step by step. The string assigned TO in MyMethod() is set
correctly...I've steped *all* the way to the actual assignment in the Test
class of set { _a = value; } and I've added a watch to the "value" field - it
IS the value of the string returned from the Method call however it does not
*actually* get set in the class.
The real fun is if I do a
string teststring = MyMethod()
mytest.a = teststring;
that works.....what the hell is going on here? I thought I might have passed
in an instance of the class that was different that the one I was using but the
use of "string teststring = MyMethod()" disproves that.
Since the watch on the set { _a = value; } shows the value that I am trying to
set, and it doesn't actually set the value then what could I be looking at here?
The MyMethod() method takes a private instance of the class and loads a set of
data into it from an xml using deserialize. If the values dont match via a crc
check then a string field gets zeroed out. Its that part that works/fails.
is *not* assigning a string, inside of a class, a value that I am passing to it
using its public set method and I can't for the life of me figure out why.
I have a class, call it Class Test with a private string _a and a public member
string a with a get{ return value; } set{ _a = value; }
I have a method, call it MyMethod() that returns a string
If I create Test mytest = new Test()
and then
mytest.a = MyMethod()
a is *not* assigned the value coming from the method function..now...here's the
kick in the pants.
I've debugged this step by step. The string assigned TO in MyMethod() is set
correctly...I've steped *all* the way to the actual assignment in the Test
class of set { _a = value; } and I've added a watch to the "value" field - it
IS the value of the string returned from the Method call however it does not
*actually* get set in the class.
The real fun is if I do a
string teststring = MyMethod()
mytest.a = teststring;
that works.....what the hell is going on here? I thought I might have passed
in an instance of the class that was different that the one I was using but the
use of "string teststring = MyMethod()" disproves that.
Since the watch on the set { _a = value; } shows the value that I am trying to
set, and it doesn't actually set the value then what could I be looking at here?
The MyMethod() method takes a private instance of the class and loads a set of
data into it from an xml using deserialize. If the values dont match via a crc
check then a string field gets zeroed out. Its that part that works/fails.