Click here to Skip to main content
15,915,864 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
If been on google everywhere and still cant find the answer to what the % do in C# programming ?
Posted

Why you can't find answer i don't understand.It's just an operator named modulus.
Consider the code..
C#
int a = 5, b = 9,c;
    c = b % a;

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..
 
Share this answer
 
Comments
Prasad_Kulkarni 11-Sep-12 2:01am    
+5! :D
ridoy 11-Sep-12 6:47am    
Thanks Prasad..
% is equivalent for Modulus and Mod is used in VB:
http://msdn.microsoft.com/en-us/library/se0w9esz%28v=vs.110%29.aspx[^]
 
Share this answer
 
Comments
Abhinav S 10-Sep-12 13:25pm    
Yup. Correct. 5.
% is called the modulus operator and computes the remainder after dividing its first operand by its second.
Refer % Operator (C# Reference)[^]
C# Modulo Operator[^]
 
Share this answer
 
Comments
Abhinav S 10-Sep-12 13:25pm    
Correct. 5.
__TR__ 11-Sep-12 2:54am    
Thanks Abhinav :)
Prasad_Kulkarni 11-Sep-12 2:01am    
+5 :D
__TR__ 11-Sep-12 2:54am    
Thanks Prasad :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900