Yuvraj Jambhle

Yuvraj Jambhle

  • NA
  • 93
  • 8.4k

how to write multiple functions in StreamWriter

Sep 21 2020 8:28 AM
Hello Friends,
Actually I want to know how to use multiple functions in StreamWriter, Streamwriter is used to write some selected content from the checklist box to notepad.
For ref. code
//Function 1
public void getSelectedColumnName()
{
string selectedColumn = "";
for (int i = 0; i < chkListBxColumnName.Items.Count; i++)
{
selectedColumn += chkListBxColumnName.Items[i] + ",";
}
StreamWriter SwriteData = new StreamWriter(@"C:\Users\user\Desktop\ReportTmplate\TemplateName.txt");
}
//Function 2
public void getSelectedTableName()
{
string selectedColumn = "";
for (int i = 0; i < chkListBxTableName.Items.Count; i++)
{
selectedColumn += chkListBxTableName.Items[i] + ",";
}
StreamWriter SwriteData = new StreamWriter(@"C:\Users\user\Desktop\ReportTmplate\TemplateName.txt");
}
//Now I want to call these above 2 functions in stream writer
private void btnWriteData_Click(object sender, EventArgs e)
{
using (StreamWriter write = new StreamWriter(@"C:\Users\user\Desktop\ReportTmplate\Template.txt"))
{
write.WriteLine(lblDBFileName.Text + " [" + cmbDBFileName.Text + "]\n");
write.WriteLine(lblDbTableName.Text + " [" + cmbDbTableName.Text + "]\n");
// Now Inside this function block, I want to use Function 1 & Function 2, below the above line.
//So please how can use this function here.
}
}

Answers (1)