在C#中添加而不添加? [英] Addition without addition in C#?
本文介绍了在C#中添加而不添加?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在不使用'+'运算符的情况下添加数字?
没有减法
解决方案
是的,当然
int a = 5 < /跨度>;
int b = 10 ;
int c = a - (-b);
使用系统;
使用 System.Collections.Generic;
使用 System.Linq;
class 计划
{
public static void Main( string [] args)
{
int a = 34 ;
int b = 55 ;
int [] array = {a,b};
int sum = array.Sum(); // 89
}
}
按位操作在C 维基百科的页面中,提供了示例 [ ^ 一>]。
Is it possible to add numbers without using the '+' operator?
WITHOUT SUBTRACTION
解决方案
Yes, of course
int a = 5; int b = 10; int c = a - (-b);
using System; using System.Collections.Generic; using System.Linq; class Program { public static void Main(string[] args) { int a = 34; int b = 55; int[] array = {a,b }; int sum = array.Sum(); //89 } }
The "Bitwise operations in C" Wikipedia's page, provides an example[^].
这篇关于在C#中添加而不添加?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文