Mahesh Babu

Mahesh Babu

  • NA
  • 1.7k
  • 367.7k

Collection Initialization (How to pass values)

Sep 20 2011 1:58 AM
By using class object we can pass values like this.

Under UI Layer
clsRegistraction register=new ClsRegistration();
string FirstName=txtFirstName.Text;
string LastName=txtLastName.Text;
string Address=txtAddress.Text;
register.InsertDetails(FirstName,LastName,Address);

Now I have one method in ClsRegistration class i.e InsertDetails()

so I can pass values like this.


Under BAL
   Public void InsertDetails(string FirstName,string LastName,string   Address)
{
      ------some code----
}


---------------------------------------------------------------------------



Now I am using List.

List<clsRegistration> register = new List<clsRegistration>();
{
new clsRegistration { FirstName=txtFirstName.Text, LastName= txtLastName.Text,Address=txtAddress.Text};
}

Now how to pass these list values that InsertDetails()  like above procedure

Should I create class object and call the method ? 
is it compalsary? 








Answers (2)