当前位置: 首页>>代码示例>>C#>>正文


C# Decimal类代码示例

本文整理汇总了C#中Decimal的典型用法代码示例。如果您正苦于以下问题:C# Decimal类的具体用法?C# Decimal怎么用?C# Decimal使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Decimal类属于命名空间,在下文中一共展示了Decimal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: grdEmpl_OnItemDataBound

 public void grdEmpl_OnItemDataBound(object sender, DataGridItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
     {
         TotalEngHours += Convert.ToDecimal(Convert.ToDecimal(e.Item.Cells[1].Text));
         TotalFabHours += Convert.ToDecimal(Convert.ToDecimal(e.Item.Cells[2].Text));
         TotalfinHours += Convert.ToDecimal(Convert.ToDecimal(e.Item.Cells[3].Text));
         TotalMiscHours += Convert.ToDecimal(Convert.ToDecimal(e.Item.Cells[4].Text));
         TotalHours += Convert.ToDecimal(Convert.ToDecimal(e.Item.Cells[5].Text));
         TotalPrice += Convert.ToDecimal(Convert.ToDecimal(e.Item.Cells[6].Text));
     }
     else if (e.Item.ItemType == ListItemType.Footer)
     {
         e.Item.Cells[1].Text = TotalEngHours.ToString();
         e.Item.Cells[1].Font.Bold = true;
         e.Item.Cells[1].HorizontalAlign = HorizontalAlign.Left;
         e.Item.Cells[2].Text = TotalFabHours.ToString();
         e.Item.Cells[2].Font.Bold = true;
         e.Item.Cells[2].HorizontalAlign = HorizontalAlign.Left;
         e.Item.Cells[3].Text = TotalfinHours.ToString();
         e.Item.Cells[3].Font.Bold = true;
         e.Item.Cells[3].HorizontalAlign = HorizontalAlign.Left;
         e.Item.Cells[4].Text = TotalMiscHours.ToString();
         e.Item.Cells[4].Font.Bold = true;
         e.Item.Cells[4].HorizontalAlign = HorizontalAlign.Left;
         e.Item.Cells[5].Text = TotalHours.ToString();
         e.Item.Cells[5].Font.Bold = true;
         e.Item.Cells[5].HorizontalAlign = HorizontalAlign.Left;
         e.Item.Cells[6].Text = TotalPrice.ToString();
         e.Item.Cells[6].Font.Bold = true;
         e.Item.Cells[6].HorizontalAlign = HorizontalAlign.Left;
     }
 }
开发者ID:frdharish,项目名称:WhitfieldAPPs,代码行数:33,代码来源:Whitfield_Payroll_ByEmployee.ascx.cs

示例2: CurrencyName

    public string CurrencyName(string Code,
                               string DecPrecise
                               )
    {
        string Name = "";        

        if (Code != "")
        {
            //不需要加入小數位判斷(DecPrecise)  因為SLP已有屬性控制
            Decimal d = new Decimal();
            if (Decimal.TryParse(Code, out d))
            {
                string tempStr = "";
                string[] d2 = d.ToString().Split('.');
                string _NT = "NT$";
                for (int i = 0; i < d2.Length; i++)
                {
                    switch (i)
                    {
                        case 0:
                            _NT += d.ToString("n").Split('.')[0];
                            break;
                        case 1:
                            _NT += d.ToString("#." + tempStr.PadRight(int.Parse(DecPrecise), '0')).Split('.')[1];
                            break;
                        default:
                            break;
                    }
                    Name = _NT;                    
                }
            }
        }        

        return Name;
    }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:35,代码来源:SLP_WUIWebService.cs

示例3: ToDecimal

 public static Decimal ToDecimal(string valueToParse, Decimal defaultValue)
 {
     Decimal returnValue;
     if (!Decimal.TryParse(valueToParse, out returnValue))
         returnValue = defaultValue;
     return returnValue;
 }
开发者ID:benjaminaaron,项目名称:SumoVizUnity_ModSem,代码行数:7,代码来源:TryParseWithDefault.cs

示例4: DoubleIsWithinEpsilon

 public static bool DoubleIsWithinEpsilon(double x, double y)
 {
     Decimal dx = new Decimal(x);
     Decimal dy = new Decimal(y);
     Decimal diff = Math.Abs(Decimal.Subtract(dx, dy));
     return diff.CompareTo(Epsilon) <= 0;
 }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:7,代码来源:mathtestlib.cs

示例5: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        switch (_PortTypeID)
        {
            case "0":
            case "1":
            case "5":
                strTableName = "UserinfoPortfolioSetting";
                break;
            case "2":
            case "6":
                strTableName = "UserinfoILPSettings";
                break;
            case "3":
                strTableName = "UserinfoSSPSettings";
                break;
            case "4":
                strTableName = "UserinfoSDPortSettings";
                break;
        }

        decTotalSize = Convert.ToDecimal(CareerCruisingWeb.CCLib.Common.DataAccess.GetValue("select isnull(cast(UploadSize/1024.0 as decimal(9,1)),0) from " + strTableName + " where SchoolID = " + _SchoolID).ToString());
        strTotalSize = (Decimal.Round(decTotalSize / 1024)).ToString();

        decFileSize = Convert.ToDecimal(CareerCruisingWeb.CCLib.Common.DataAccess.GetValue("select isnull(cast(sum(FileSize)/1024.0 as decimal(9,1)),0) from Port_Files where PortfolioID = " + _PortfolioID).ToString());

        decPercent = decFileSize / decTotalSize * 100;

        imgProgress.Width = Convert.ToInt16(decPercent/100 * 161);
    }
开发者ID:nehawadhwa,项目名称:ccweb,代码行数:30,代码来源:FileUsage.ascx.cs

示例6: PosTest2

    public bool PosTest2()
    {
        bool retVal = true;
        const string c_TEST_DESC = "PosTest2:Verify the param is UInt64.MinValue(0) ";
        const string c_TEST_ID = "P002";

        UInt64 dValue = UInt64.MinValue;
        Decimal resValue = 0m;

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);

        try
        {
            Decimal decimalValue = new Decimal(dValue);
            if (decimalValue != resValue)
            {
                string errorDesc = "Value is not " + resValue.ToString() + " as expected: param is " + decimalValue.ToString();
                TestLibrary.TestFramework.LogError("003" + " TestId-" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004" + " TestId-" + c_TEST_ID + " TestId-" + c_TEST_ID, "Unexpected exception: " + e);
            retVal = false;
        }


        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:30,代码来源:decimalctor8.cs

示例7: PosTest1

    public bool PosTest1()
    {
        bool retVal = true;
        const string c_TEST_DESC = "PosTest1:Verify the param is a random float ";
        const string c_TEST_ID = "P001";

        float dValue = TestLibrary.Generator.GetSingle(-55);
        while (dValue > Convert.ToSingle(Decimal.MaxValue) || dValue < Convert.ToSingle(Decimal.MinValue))
        {
            dValue = TestLibrary.Generator.GetSingle(-55);
        }

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);

        try
        {
            Decimal decimalValue = new Decimal(dValue);
            if (decimalValue != Convert.ToDecimal(dValue))
            {
                string errorDesc = "Value is not " + decimalValue.ToString() + " as expected: param is " + dValue.ToString();
                TestLibrary.TestFramework.LogError("001" + " TestId-" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002" + " TestId-" + c_TEST_ID + " TestId-" + c_TEST_ID, "Unexpected exception: " + e);
            retVal = false;
        }


        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:33,代码来源:decimalctor6.cs

示例8: f

 private static int f(short a1, ushort a2, int a3, uint a4, long a5,
         ulong a6, byte a7, sbyte a8, Decimal a9, int[] a10,
         VT a11, CL a12, int a13, int a14, int a15,
         int a16, int a17, int a18, int a19, int a20,
         int a21, int a22, int a23, int a24, int a25)
 {
     Console.WriteLine(a1);
     Console.WriteLine(a2);
     Console.WriteLine(a3);
     Console.WriteLine(a4);
     Console.WriteLine(a5);
     Console.WriteLine(a6);
     Console.WriteLine(a7);
     Console.WriteLine(a8);
     Console.WriteLine(a9);
     Console.WriteLine(a10[0]);
     Console.WriteLine(a11.m);
     Console.WriteLine(a12.n);
     Console.WriteLine(a13);
     Console.WriteLine(a14);
     Console.WriteLine(a15);
     Console.WriteLine(a16);
     Console.WriteLine(a17);
     Console.WriteLine(a18);
     Console.WriteLine(a19);
     Console.WriteLine(a20);
     Console.WriteLine(a21);
     Console.WriteLine(a22);
     Console.WriteLine(a23);
     Console.WriteLine(a24);
     Console.WriteLine(a25);
     int sum = f1(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15,
             a16, a17, a18, a19, a20, a21, a22, a23, a24, a25);
     return sum;
 }
开发者ID:l1183479157,项目名称:coreclr,代码行数:35,代码来源:25param2a.cs

示例9: FloatIsWithinEpsilon

 public static bool FloatIsWithinEpsilon(float x, float y)
 {
     Decimal dx = new Decimal(x);
     Decimal dy = new Decimal(y);
     Decimal diff = Math.Abs(Decimal.Subtract(dx, dy));
     return diff.CompareTo(Epsilon) <= 0;
 }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:7,代码来源:mathtestlib.cs

示例10: Distribute

 public static Money[] Distribute(this Money money,
     FractionReceivers fractionReceivers,
     RoundingPlaces roundingPlaces,
     Decimal distribution)
 {
     return new MoneyDistributor(money, fractionReceivers, roundingPlaces).Distribute(distribution);
 }
开发者ID:madhon,项目名称:money-type-for-the-clr,代码行数:7,代码来源:MoneyExtensions.cs

示例11: Oprema

 /*public Oprema(int id, int kolicina, Decimal cijena, string tipOpreme) : base(kolicina)
 {
     IdOpreme = id;
     if (tipOpreme == "Bandaze") TipOpreme = TipOpreme.Bandaze;
     if (tipOpreme == "Flasa") TipOpreme = TipOpreme.Flasa;
     if (tipOpreme == "Peskir") TipOpreme = TipOpreme.Peskir;
     if (tipOpreme == "Pojas") TipOpreme = TipOpreme.Pojas;
     if (tipOpreme == "Rukavice") TipOpreme = TipOpreme.Rukavice;
     if (tipOpreme == "Sorts") TipOpreme = TipOpreme.Sorts;
     if (tipOpreme == "Tene") TipOpreme = TipOpreme.Tene;
     CijenaNajama = cijena;
     tipopremes = tipOpreme;
 }*/
 public Oprema(int id, int kolicina, Decimal cijena, String tipOpreme)
     : base(kolicina)
 {
     IdOpreme = id;
     CijenaNajama = cijena;
     TipOpremeS = tipOpreme;
 }
开发者ID:vatoN1,项目名称:Teretana,代码行数:20,代码来源:Oprema.cs

示例12: Main

 public static int Main(String[] args)
 {
     Decimal[] dcmlSecValues = new Decimal[2] { 2, 3 };
     Int32 aa = 1;
     Decimal dcml1 = --dcmlSecValues[aa];
     return 100;
 }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:7,代码来源:b14716.cs

示例13: STD_CBEExamSubject

 public STD_CBEExamSubject(
     int cBEExamSubjectID, 
     int cBEExamID, 
     string subjectTitle, 
     string subjectCode, 
     string taxOrPaperVariant, 
     Decimal fees,
     DateTime examDate, 
     string addedBy, 
     DateTime addedDate, 
     string updatedBy, 
     DateTime updatedDate, 
     int rowStatusID
     )
 {
     this.CBEExamSubjectID = cBEExamSubjectID;
     this.CBEExamID = cBEExamID;
     this.SubjectTitle = subjectTitle;
     this.SubjectCode = subjectCode;
     this.TaxOrPaperVariant = taxOrPaperVariant;
     this.Fees = fees;
     this.ExamDate = examDate;
     this.AddedBy = addedBy;
     this.AddedDate = addedDate;
     this.UpdatedBy = updatedBy;
     this.UpdatedDate = updatedDate;
     this.RowStatusID = rowStatusID;
 }
开发者ID:anam,项目名称:mal,代码行数:28,代码来源:STD_CBEExamSubject.cs

示例14: Suplement

 public Suplement(int id, int kolicina, Decimal cijena, String tipSuplementa)
     : base(kolicina)
 {
     IdSuplementa = id;
     TipSuplementaS = tipSuplementa;
     Cijena = cijena;
 }
开发者ID:vatoN1,项目名称:Teretana,代码行数:7,代码来源:Suplement.cs

示例15: PosTest1

    public bool PosTest1()
    {
        bool retVal = true;
        const string c_TEST_DESC = "PosTest1:Verify the param is a random UInt64 ";
        const string c_TEST_ID = "P001";

        System.UInt64 uint64Value = Convert.ToUInt64(TestLibrary.Generator.GetInt64(-55));

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);

        try
        {
            Decimal decimalValue = new Decimal(uint64Value);
            if (decimalValue != Convert.ToDecimal(uint64Value))
            {
                string errorDesc = "Value is not " + Convert.ToDecimal(uint64Value).ToString() + " as expected: param is " + decimalValue.ToString();
                TestLibrary.TestFramework.LogError("001" + " TestId-" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002" + " TestId-" + c_TEST_ID + " TestId-" + c_TEST_ID, "Unexpected exception: " + e);
            retVal = false;
        }


        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:29,代码来源:decimalctor8.cs


注:本文中的Decimal类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。