如何在C#中打印动态字符串值? [英] How to print dynamic string value in C#?

查看:251
本文介绍了如何在C#中打印动态字符串值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好。



我有一个string类型的变量。这个变量包含一个字符串值。

如果0为0,

2编号为0,1行。因此,如果学生变量与0不同,我想打印此值。

我想打印学生变量(如果它与0不同)

例如;我想打印如果数字值得以下方式。



[0] Paul string

[1] Christina string



Console.WriteLine(学生名,学生);



我想打印:影响亚历克斯,玛丽



如何以这种方式打印?



我是什么尝试过:



Hello.

I have a variable of type string.This variable holds a string value.
If 0 is 0,
2 is numbered 0,1 lines. So if the student variable is different from 0 I would like to print this value.
I want to print the Students variable (if it is different from 0)
For example ; I want to print if the numbers are worth the following way.

[0] Paul string
[1] Christina string

Console.WriteLine ("studentnames", students);

I want to print: effected Alex, Mary

How do I print this way?

What I have tried:

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

推荐答案

我不确定我是否完全理解你的问题,但仍然提出解决方案根据我的理解。我想你需要尝试这样的事情:



I am not sure if i understood your problem completely, but still proposing a solution based on my understanding. I think you need to try something like this:

for(var i= 0; i < students.Count; i++)
{
    Console.WriteLine("[" + i.ToString() + "] " + students[i] + Environment.Newline);
}


这篇关于如何在C#中打印动态字符串值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆