Casting VS Converting VS Parsing in C#: Which to choose?

Casting VS Converting VS Parsing in C#: Which to choose?

tutorialsEU

2 года назад

9,647 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Atif Ahsan
Atif Ahsan - 04.03.2023 10:34

Hey,

I noticed you didn't include details of Casting VS Converting VS Parsing in your UDEMY master class course. I think it's an important video, so pls add it to the course

Ответить
Guillermo Mazzari
Guillermo Mazzari - 02.03.2023 07:44

Thanks for sharing! I have a list of strings, I need to convert some of those values to Decimals, I have a class called "Promedio" with some values that are type decimal. I'm writing th following code:

List<string> values (this is the list with all the string values, they come from several inputs form the user)

then im using my class "Promedio" to create a new object and trying to set the values of the List to the fields of my class, like this:

Promedios promedio = new()
{
C1 = Convert.ToDecimal(values[0]),
C2 = Convert.ToDecimal(values[1]),
Leaf = Convert.ToDecimal(values[2]),
Stpl = Convert.ToDecimal(values[3]),
Mic = Convert.ToDecimal(values[4])
}

but instead of returning decimal values, it returns items like this:

values[0] = "1.2367"

and C1 ends up being: 12376

I tried several solutions but I dont know what else to do, please help

Ответить
abugsbunny
abugsbunny - 20.12.2022 14:44

Great. Many thanks

Ответить
Soroush JM
Soroush JM - 22.11.2022 08:32

Nice
Just boosting algorithm

Ответить
Mert Kurt
Mert Kurt - 20.06.2022 19:17

very helpful and also i liked try and catch :) many thanks

Ответить
Sunny Frankins
Sunny Frankins - 17.06.2022 18:39

but WHY are they different though?

Ответить
Vĩnh Nghị Đặng
Vĩnh Nghị Đặng - 15.03.2022 10:20

thank you alot!

Ответить
Petko Lambev
Petko Lambev - 13.02.2022 11:20

very useful, thanks!

Ответить
Fulgence Junior Lohore
Fulgence Junior Lohore - 01.10.2021 00:09

Useful!

Ответить
Philippe Lhermie Traderchange
Philippe Lhermie Traderchange - 13.09.2021 23:14

Always interesting as usual... But what happened to your voice???? Where is the Castafiore??? ;)

Ответить
Adam Michael
Adam Michael - 13.09.2021 18:06

How to create a desktop clock(widget) in C# for window 10? Can you make a tutorial on that please?

Ответить