[英]variable variable name C#
I am new in C#, I use to program PHP.我是 C# 新手,我用来编程 PHP。
I want to do same thing that is done in PHP code below for C#.我想做与 C# 下面的 PHP 代码中所做的相同的事情。
<?php
for($i=0;$i<10;$i++)
{
$tempVar="$newVar".$i;
echo $$tempVar; //to print the content of $newVar0 to $newvar9
}
?>
Is the same option, of changing variable name dynamically, available in C#.是相同的选项,动态更改变量名称,在 C# 中可用。 Please Guide.
请指导。 Thank you
谢谢
PHP and C# both have very different syntax. PHP 和 C# 都有非常不同的语法。 You must start learning by yourself from online tutorials.
您必须从在线教程开始自学。 Your answer is
你的答案是
var newVar ="This is test";
var var1= newVar;
Console.WriteLine(var1);
Tutorial Sources (learn step by step)教程来源(一步一步学习)
http://www.tutorialspoint.com/csharp/ http://www.tutorialspoint.com/csharp/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.