c# - How do i send a data from one form to function of another class -


i know how pass data 1 form form, how can pass data 1 form class. data want pass form1 class question:

string grpid = "somevalue"; string durationid = "somevalue";` 

i searched didn't got exact answer this.

class question {     string groupid="here want value of groupid,how can this";     string duraid="and here value of durationid";      // can use them here     public ienumerable<question> getquestions(string topicid, int marks)     {         string sql = "select qid,question,opt1,opt2,opt3,opt4,ansop,marks questions topicid in(" +                      topicid + ") , marks=" + marks.tostring();         var cmd = new oledbcommand(sql, new oledbconnection(@"provider=microsoft.jet.oledb.4.0;data source=db1.mdb"));         var rs = cmd.executereader();          if (rs != null)         {             while (rs.read())             {                 yield return                     new question                     {                         id = rs[0].tostring(),                         text = rs[1].tostring(),                         option1 = rs[2].tostring(),                         option2 = rs[3].tostring(),                         option3 = rs[4].tostring(),                         option4 = rs[5].tostring(),                         answeroption = rs[6].tostring(),                         marks = marks                     };             }         }     } } public void foo()//in function can pass `string[] conf` here?         {             var totqsn = convert.toint16(conf[0]); // isn't sum of else?             var mark1qsn = convert.toint16(conf[3]); //this variable contains number of question display of mark 1             var mark2qsn = convert.toint16(conf[4]);             var mark3qsn = convert.toint16(conf[5]);             var mark4qsn = convert.toint16(conf[6]);              var mark1questionset = getquestions(topicid, 1).tolist();             var mark2questionset = getquestions(topicid, 2).tolist();            } 

add method class:

class question {     public void somefunction(string grpid, string durationid)    {         ...    }  } 

then can call form:

questioninstance.somefunction("somevalue","somevalue"); 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -