কম্পিউটার টিউটোরিয়াল

C#-এ Decimal.Negate() মেথড


C#-এ Decimal.Negate() মেথডটি নির্দিষ্ট Decimal মানকে ঋণ এক (-1) দিয়ে গুণ করে ফলাফল ফেরত দেয়।

সিনট্যাক্স

নিচে সিনট্যাক্স দেওয়া হলো:

public static decimal Negate (decimal val);

উপরে, val হল নেগেট করার মান।

উদাহরণ

Decimal.Negate() মেথড বাস্তবায়নের প্রথম উদাহরণ:

using System;
public class Demo {
    public static void Main(){
        Decimal val = 3972.491M;
        Console.WriteLine("Decimal Value = {0}", val);
        Console.WriteLine("HashCode = {0}", (val.GetHashCode()));
        TypeCode type = val.GetTypeCode();
        Console.WriteLine("TypeCode = " + type);
        Decimal res = Decimal.Negate(val);
        Console.WriteLine("Negative (Decimal) = " + res);
    }
}

আউটপুট

এটি নিচের আউটপুট তৈরি করবে:

Decimal Value = 3972.491
HashCode = 620041307
TypeCode = Decimal
Negative (Decimal) = -3972.491

ঋণাত্মক মান নেগেট করা

ঋণাত্মক মান নেগেট করলে ধনাত্মক মান পাওয়া যায়:

using System;
public class Demo {
    public static void Main(){
        Decimal val = -29.35m;
        Console.WriteLine("Decimal Value = {0}", val);
        Console.WriteLine("HashCode = {0}", (val.GetHashCode()));
        TypeCode type = val.GetTypeCode();
        Console.WriteLine("TypeCode = " + type);
        Decimal res = Decimal.Negate(val);
        Console.WriteLine("Negative (Decimal) = " + res);
    }
}

আউটপুট

এটি নিচের আউটপুট তৈরি করবে:

Decimal Value = -29.35
HashCode = 1503969289
TypeCode = Decimal
Negative (Decimal) = 29.35

  1. C#-এ Decimal.ToSByte() পদ্ধতি

  2. C#-এ Decimal.ToOACurrency() পদ্ধতি

  3. C#-এ Decimal.Floor() মেথড

  4. C#-এ Decimal.Divide() মেথড