Click here to Skip to main content
15,900,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello there.
I have a string list, and I'm holding students if the student is successful.
So I want to print successful students.
Can I print the list string value as follows?

public List<string> students=new List<string>();

In additon,Should I send the string list value parameter this way.(List<string>)


public static void Send(path,int numberid,List<string> students,content)   
{
   
}


What I have tried:

if( //coding !=0)
{
SendFiles.Send(path,numberid,**students**,"successful");
File.AppendAllText(path, numberid,students + Environment.NewLine);
}
Posted
Updated 21-Feb-19 16:06pm
v2
Comments
BillWoodruff 22-Feb-19 9:39am    
When you say "print," I think you mean write a file ... is that correct ?

1 solution

Quote:

Can I print the list string value as follows?
public List<string> students=new List<string>();

hmmm. Short answer no. because there hardly any code there beside the variable declaration. Here is an example on how to print a list: https://www.dotnetperls.com/list[^]

Quote:
In additon,Should I send the string list value parameter this way.(List<string> students)

That look ok.

Simple example:
C#
List<string> students = new List<string>();
students.Add("student 1");
students.Add("student 2");
students.Add("student 3");
students.Add("student 4");

foreach (string student in students) {
	Console.WriteLine(student);
}


By the way, the send method look odd, I think it should look something like

C#
public static void Send(string path, int numberid, List<string> students, string content)   
{
   
}
 
Share this answer
 

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