double转换成分数在C#中的字符串 [英] Convert double to fraction as string in C#
本文介绍了double转换成分数在C#中的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要显示double值在C#分数,我该怎么做呢?
I want to display double value as fraction in C#, how can I do this ?
感谢
推荐答案
试试这个分数类C#
由于@Tillito在评论中指出,我双用以下代码检查:
As @Tillito points out in comment, I double checked with the following codes:
using System.IO;
using System;
using Mehroz;
class Program
{
static void Main()
{
double d = .5;
string str = new Fraction(d).ToString();
Console.WriteLine(str);
}
}
它输出:
which outputs:
1/2
下面是演示项目:的 http://goo.gl/QPy9yw
这篇关于double转换成分数在C#中的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文