本文介绍了在C#中写入列表字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好。

我有一个字符串列表,如果学生成功,我会抓住学生。

所以我想打印成功的学生。 />
我可以按如下方式打印列表字符串值吗?



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



另外,我应该以这种方式发送字符串列表值参数。(List< string>)





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

}





我尝试过:



 if(// coding!= 0)
{
SendFiles.Send(path,numberid,** students **,success) );
File.AppendAllText(path,numberid,students + Environment.NewLine);
}
解决方案



hmmm。简短的回答没有。因为变量声明旁边几乎没有任何代码。以下是如何打印列表的示例: []





看起来不错。



简单示例

列表< string> ; students =  new  List< string>(); 
students.Add( student 1);
students.Add( student 2);
students.Add( student 3);
students.Add( student 4);

foreach string student 学生中){
Console.WriteLine(学生);
}





顺便说一下,发送方法看起来很奇怪,我认为应该看起来像



  public   static   void 发​​送(字符串路径, int  numberid,List< string> students, string  content)
{

}


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);
}
解决方案


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[^]


That look ok.

Simple example:

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

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

}


这篇关于在C#中写入列表字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 08:25