小编use*_*145的帖子

是否可以将数学运算 (+) 存储在变量中并调用该变量,就像直接使用运算本身一样

我知道这是一个奇怪的问题,但这里有一段代码可以更好地解释我想要做什么。

char plus = '+'; //Creating a variable assigning it to the + value.
//Instead of using + we use the variable plus and expect the same outcome.     
Console.WriteLine(1 + plus + 1); 
Console.ReadLine(); //Read the line.
Run Code Online (Sandbox Code Playgroud)

但由于某种原因,控制台读出了 45...很奇怪吧?那么,如果您明白我想要做什么,您能解释一下并告诉我如何做吗?

c# math variables

1
推荐指数
1
解决办法
3427
查看次数

标签 统计

c# ×1

math ×1

variables ×1