C#变量声明 [英] C# variable declaring

查看:83
本文介绍了C#变量声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我的静止是关于VFox中的变量:


字符串变量;

for(int i = 0; i = 10; i ++)

{

变量=" mem" + i.SoString();

//现在部分我需要在狐狸中找到一些解决方案喜欢这个&变量

string& variable;


}

mem2 =" Somthing ..." ;;


所以问题是从其他变量中的数据声明变量的简单方法....


Thx

Ok my quiestion is about varibles something like in VFox:

string variable;
for(int i=0; i=10 ; i++)
{
variable = "mem"+i.SoString();
// now part i need some solution in fox would be like this &variable
string &variable;

}
mem2 = "Somthing...";

So question is easy way to declare variable from data in other variable....

Thx

推荐答案

我不知道你想要实现的目标是什么。你想连接字符串吗?如果是这样,你可以使用+ =运算符:
I have no idea what the goal you are trying to achieve is. Are you trying to concatenate strings? If so, you can use the += operator:
展开 | 选择 | Wrap | 行号


1。)小心输入。 ToString!= SoString和

for(int i = 0; i = 10; i ++)!= for(int i = 0; i< 10; i ++)

2 。)不要使用+来循环连接字符串。请改用StringBuilder。
1.) Careful with your typing. ToString != SoString and
for(int i =0; i=10;i++) != for(int i = 0; i<10;i++)
2.) Do not use + to concatenate strings in a loop. Use a StringBuilder instead.


C#不是解释语言,所以你不能在运行时创建变量。

但是,你可能想检查反射,你在哪里可以在运行时编译并加载
代码。我已经用它来创建类和从创建的类中设置对象

,然后从中调用方法。
C# is not interpreted language, so you cannot create variables at the runtime.
However, you might like to check reflection, where you can compile and load
code at the runtime. I have used it in creating classes and instatiating objects
from the created classes and then calling methods from it.


这篇关于C#变量声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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