Link to home
Start Free TrialLog in
Avatar of cyimxtck
cyimxtckFlag for United States of America

asked on

C# Properties getting null values back instead of actual values

I am trying to have a form which gets submitted and passes various text box parameters down along the way.  So I have properties in class for that with private strings (didn't use the auto-implemented properties but tried both).

Here is where the values originate from a WPF form:

            var exe = new DataReadWrite();
            var uv = new UserValues();

            uv.strFirstName = tbxFirstName.Text;
            uv.strLastName = tbxLastName.Text;
            uv.strEmailAddress = tbxEmailAddress.Text;

            exe.exeInsUser();

In the debugger the values above are populated...

Now when exeInsUser() chokes, it is due to the values being null as here:

separate class to hold the values:

    public class UserValues
    {
        private String firstname;
        private String lastname;
        private String emailaddress;

        public string strFirstName
        {
            get
            {
                return firstname;
            }

            set
            {
                firstname = value;
            }
        }

        public string strLastName
        {
            get
            {
                return lastname;
            }

            set
            {
                lastname = value;
            }
        }

        public string strEmailAddress
        {
            get
            {
                return emailaddress;
            }

            set
            {
                emailaddress = value;
            }
        }


The execution fails here with a null reference exception:

separate class to execute:

            var oPa = new DataParameters();
            var str = new UserValues();

            StoredProcParameter[] oPL = oPa.insUsersParm( str.strFirstName
                                                        , str.strLastName
                                                        , str.strEmailAddress);

I even tried implementing an interface (although the code above has this removed in the implementation) but everything is null!?

Any help is greatly appreciated!
ASKER CERTIFIED SOLUTION
Avatar of Daniel Van Der Werken
Daniel Van Der Werken
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cyimxtck

ASKER

I am not passing them right there I am getting them later in another routine from the UserValues.

In the bottom half of the original post:

separate class to execute:

            var oPa = new DataParameters();
            var str = new UserValues();

            StoredProcParameter[] oPL = oPa.insUsersParm( str.strFirstName
                                                        , str.strLastName
                                                        , str.strEmailAddress);
public void exeInsUser()
        {
            insUsers();
        }
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perfect!