Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I am new to C#. I have an application which calls a DataBaseIO class method to read through an SQL database table. This method creates a new instance of a User object and populates the instance with data read from the input table. In debug I can see that the instance is updated with the correct data.

However when control returns from this DataBaseIO method to the calling method ,the object is null. The calling method is in source Transaction.cs and the object is created in DataBaseIO.cs. How can I pass the object back to the calling method in Transaction.cs ?

regards
Pat
Posted

1 solution

Make the return value of the method in the DataBaseIO class return the User Object it creates to the call-site of the method in the Transaction class.

If you can call method in DataBaseIO, as you indicate, that means, to me, that your Transaction class has a valid reference to it.

Or, if you don't wish to expose the "whole" User Type object, you could create accessor methods in the DataBaseIO class that selectively exposed what you wished to expose in the User Type object.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900