Try
public bool IsDivisible(int x, int n)
{
return (x % n) == 0;
}
The modulus operator % returns the remainder after dividing x by n which will always be 0 if x is divisible by n.
For more information, see the % operator on MSDN.
Related Contents:
- What is the correct way to create a single-instance WPF application?
- What can I use for good quality code coverage for C#/.NET? [closed]
- Showing Difference between two datetime values in hours
- Difference between Lookup() and Dictionary(Of list())
- Reading CSV files using C#
- How to disable editing of elements in combobox for c#?
- Why does integer division in C# return an integer and not a float?
- Convert any object to a byte[]
- How to remove all the null elements inside a generic list in one go?
- DateTime format to SQL format using C#
- How to send a Post body in the HttpClient request in Windows Phone 8?
- How to use await in a loop
- Could not create SSL/TLS secure channel, despite setting ServerCertificateValidationCallback
- Explanation of Func
- WPF App Doesn’t Shut Down When Closing Main Window
- How to check if a windows service is installed in C#
- Azure Functions Database Connection String
- Getting path relative to the current working directory? [duplicate]
- MongoDB C# Driver – Ignore fields on binding
- ASP .NET MVC Disable Client Side Validation at Per-Field Level
- Get all derived types of a type
- How to find all the classes which implement a given interface?
- How can I use Dependency Injection in a .Net Core ActionFilterAttribute?
- How do I center a window on the screen in C# & WinForms?
- TimeZoneInfo in .NET Core when hosting on unix (nginx)
- Await Tasks in Test Setup Code in xUnit.net?
- Why are C# structs immutable?
- AutoFixture – configure fixture to limit string generation length
- C# Anonymous types cannot be assigned to — it is read only
- Creating API that is fluent
- MongoDB C# Driver: Ignore Property on Insert
- Need guide line for MVC action method with Bind attribute
- Is static context always single in C#?
- Checkbox disabled attribute in ASP.NET MVC
- What open-source QR Code Generator would you recommend? [closed]
- Interface with generic parameter vs Interface with generic methods
- What is the equivalent datatype of SQL Server’s Numeric in C#
- Why is Graphics.MeasureString() returning a higher than expected number?
- User in Entity type MVC5 EF6
- How to get a Brush from a RGB Code?
- FluentValidation – Validating a View Model that contains a list of an Object
- C# Compiler Warning 1685
- C# implementation of deep/recursive object comparison in .net 3.5
- Convert a username to a SID string in C#/.NET
- Remove ‘\’ char from string c#
- Can C# generics have a specific base type?
- Adding stored procedures complex types in Entity Framework
- How do I authenticate a WebClient request?
- Exception from HRESULT: 0x80070057 (E_INVALIDARG)
- How to create custom additional fields in UserProfile in MVC4