Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send decimal as a argument in the c# method

Tags:

c#

arguments

I have a simple class which has a constructor in this manner:

public Components(int sNo, string componentName, string fileType, **decimal size**, int totalDownloads, string filePath, **decimal price**, string description)

i'm trying to send the arguments by calling this statement:

new DatabaseObjects.Components(1, "CC Cleaner", "exe", **2,84**, 0, @"C:\Users\admin\Desktop\Software_Components\CCCleaner.exe", **5,00**, "To clean up junk files and invalid Registry entries")

But as you can see when i try to send the arguments in this way it is not taking 2,84 as one value it is taking 2 as one argument and 84 as one argument.

and when i try to replace ,with . i mean 2,84 as 2.84

it is saying cannot convert double to decimal.

How can i solve this problem ?

Please help me

like image 864
Sree Avatar asked Oct 17 '25 10:10

Sree


1 Answers

Use the decimal literal 2.84m.

Plain 2.84 is parsed as a double, which cannot be implicitly converted to a decimal.

like image 122
Frédéric Hamidi Avatar answered Oct 19 '25 01:10

Frédéric Hamidi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!