dotnet-Snippets.com
Snippets: 75 | Registered User: 84 | Visitors online: 9
Main Menu

Home
Random Snippet
FAQs
Contact Us
Imprint
RSS Feeds

Rss All languages
Rss C#
Rss VB.NET
Rss C++
Rss J#
Rss ASP.NET
Jobs

dotnet Jobs
Google Ads

Sri Lanka .NET 
                Forum Member
Percentage

Author: Guest
Programming Language: C# Rating:
not yet rated

Views: 160

Description:

Returns a percent value of a number out of a given maximum.



C#
1
2
3
4
5
6
7
8
9
10
11
public double Percent(double value, double max)
{
     return ((value * 100) / max);
}

public int Percent(int value, int max)
{
     return ((value * 100) / max);
}

// Either works, but the double method is more precise.

This Snippets could be interesting for you:

Poor Excellent
1 2 3 4 5 6 7 8 9 10
Sign in to vote for this snippet.

Comments:
(Please log in to write an comment.)