how to pass a variable to another class by using c#?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lazzypink
    New Member
    • Mar 2008
    • 15

    how to pass a variable to another class by using c#?

    hi mate! i'm showing just a part of my source code. i need to pass the 'GetSeconds' variable to my SqlDB. can somebody show me how to pass it? what should i need to add in? thanks for the kindly help..

    namespace test
    {
    public partial class test : Form
    {
    private long GetSeconds(int hour, int minutes)
    {
    if ((hour != 0) && (minutes!=0))
    return ((hour*3600) + (minutes * 60));
    else if (hour != 0)
    return (hour * 60 * 60);
    else
    return (minutes * 60);
    }
    }
    }


    namespace test
    {
    class SqlDB
    {
    private void RecoverSchedule ()
    {
    switch (Convert.ToInt3 2(myReader.GetV alue(myReader.G etOrd inal("Interval_ Type"))))
    {
    case 1:
    Interval = GetSeconds(0, Convert.ToInt32 (myReader.GetVa lue(myReader.Ge tOrdi nal("Interval_T ime"))));
    break;
    }
    }
    }
  • Shashi Sadasivan
    Recognized Expert Top Contributor
    • Aug 2007
    • 1435

    #2
    GetSeconds looks like a method (rather than a variable)

    Moreover the value that GetSeconds Returns is stored into Interval.

    You have to either use and update or insert statement to update the database accordingly.

    Comment

    • lazzypink
      New Member
      • Mar 2008
      • 15

      #3
      Originally posted by Shashi Sadasivan
      GetSeconds looks like a method (rather than a variable)

      Moreover the value that GetSeconds Returns is stored into Interval.

      You have to either use and update or insert statement to update the database accordingly.
      hi! thanks. i'm sorry didn't state my Question clearly. i just wonder how to pass the GetSeconds from my test class to my sqlDB class where the underlined GetSeconds what should i add on?? is it "test.GetSecond s"? i try before but is an error....can you show me the correct answer? thanks!

      Comment

      Working...