Click here to Skip to main content
15,886,104 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
for stock management

How to Convert Tonnes To Kilograms
How to Convert dozen To pic
How to Convert kilograms To grams
in windows application c#

What I have tried:

How to Convert unit in windows application c#
Posted
Updated 3-Aug-17 19:56pm
Comments
Nelek 4-Aug-17 1:52am    
1 Tonne = 1000 Kg
1 Kg = 1000 Gr
1 dozen = 12 pieces

Hope it helps :)

For each of these units, write a function that takes an argument (the original value) and returns the converted value:
C#
float TonnesToKilograms(float tonnes)
{
    return tonnes * 1000;
}
// ... and so on

And, whenever you need to do a conversion in your application, just call one of these functions like this:
C#
int kg = TonnesToKilograms(1.5); // but with an actual value passed in rather than 1.5
 
Share this answer
 
v2
Comments
CPallini 4-Aug-17 3:30am    
5.
Set up an input control - a NumericUpDown is a good choice - and use that to get the user value to convert.
Then,
To Convert Tonnes To Kilograms : multiply by 1000
To Convert dozen To pic : work out what a "pic" is, find out the conversion rate, and multiply by that
To Convert kilograms To grams : multiply by 1000

Then use a control or a MessageBox to display the converted value

But this your homework, so I'll give you no code!
 
Share this answer
 
Comments
Nelek 4-Aug-17 2:07am    
I suppose pic = pieces?
OriginalGriff 4-Aug-17 2:13am    
I'm guessing so, but ... who knows?
Nelek 4-Aug-17 2:19am    
Yeah... with such a questioner skills, one never knows
jyoti jodha 4-Aug-17 2:28am    
how to write Query for this......???
OriginalGriff 4-Aug-17 3:30am    
You are going to have to elaborate on that: we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.
And the concept of "Query" doesn't really exist in C#, that's more a database thing which doesn't seem very applicable in this project.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900