C#中%的含义是什么 [英] Whats the meaning of % in C#

查看:160
本文介绍了C#中%的含义是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果到处都是Google,但仍然找不到%在C#编程中做什么的答案?

If been on google everywhere and still cant find the answer to what the % do in C# programming ?

推荐答案

%被称为模运算符并计算余数将第一个操作数除以第二个操作数后.
请参考%运算符(C#参考) [ C#模运算符 [ ^ ]
% is called the modulus operator and computes the remainder after dividing its first operand by its second.
Refer % Operator (C# Reference)[^]
C# Modulo Operator[^]


%等效于Modulus,并且在VB中使用Mod:
http://msdn.microsoft.com/en-us/library/se0w9esz%28v = vs.110%29.aspx [ ^ ]
% is equivalent for Modulus and Mod is used in VB:
http://msdn.microsoft.com/en-us/library/se0w9esz%28v=vs.110%29.aspx[^]


为什么您找不到我不明白的答案.它只是一个运算符命名模数.
考虑一下代码.
Why you can''t find answer i don''t understand.It''s just an operator named modulus.
Consider the code..
int a = 5, b = 9,c;
    c = b % a;


如果现在打印c,则它将打印4,因为当您将9除以5时,余数将是4.这就是%的工作.


If you now print c then it will print 4,because when you divide 9 by 5 then the remainder will be 4.That''s the work what % does..


这篇关于C#中%的含义是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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