Questions tagged as '.net'

2
answers

Wrong date calculation

I have the following method: TimeSpan dt = dataFinal.Subtract(dataInicial); double anos = Math.Floor(dt.Days / 365.25); double meses = Math.Floor(((dt.Days - anos * 365.25) / 30)); return string.Format("{0} Anos e {1} mês(es)", anos, meses);...
asked by 11.03.2015 / 15:38
3
answers

How to transform a bool into int?

I'm trying to do the following: if the guess value ( _TextValPalite ) is enabled then it will check if that number is not different from a minimum value and a maximum value. Ex: between 1 and 10 I can write 5, but not 11. if(_TextValP...
asked by 20.05.2016 / 14:45
1
answer

What is the best type to store area, volume, perimeter? [duplicate]

Decimal , Numeric or Float . What is the best option to store area or volume? I would use Decimal, but I would like to see the views of others as well. It does not seem like it, but the right kind or the closest of that make...
asked by 21.11.2017 / 17:56
2
answers

Remove the time part of a date in C #

This is not working right here: DateTime? _data = calDataExclusao.Date; string nova_data = _data.ToString("dd/mm/yyyy"); The error is:    No overload for method 'ToString' takes 1 arguments How do I remove the time part of a date?  ...
asked by 08.12.2015 / 17:03
3
answers

Keep zero after the comma using float type?

I have a database where product values are stored. When zero numbers occur after the commas they come with zero. I did a test and with decimal it worked, but my application uses float , so I need to work with float . decimal numero = d...
asked by 03.02.2014 / 18:08
2
answers

How do I shut down, restart, sleep programmatically?

I would like to add these options to a program, after finishing a task the computer would be shut down / restarted / placed in sleep . How can I do this?     
asked by 21.12.2013 / 03:23
1
answer

What causes the 'System.NullReferenceException'?

Sometimes the execution of my systems is interrupted by this error, when it happens, a if(atributo != null) usually resolves, but this pollutes the code, "Ah, but this variable must have a value right?" the problem happens just when I assi...
asked by 30.12.2015 / 13:53
2
answers

Referencing folders created in the project

After I go to Project > Add > New Folder, rename the folder and put classes inside it I can no longer reference it in another file, for example if it were to be used in a controller , I would use as always I used the using nomeProjeto.N...
asked by 21.12.2015 / 14:08
1
answer

Can I create a Win32 application in C #?

I am aware that C # is the right arm of the .NET Framework, and that the default language for programming Win32 applications is C ++. But, can I program an application in C #, regardless of any .NET Framework library? In other words, I can cr...
asked by 08.08.2017 / 05:53
2
answers

What is the difference between async Task and void?

I use async Task with await when I need my code to wait for this task to complete until I run another process. In the case of void methods, without async-await , does my code also not "wait" to execute another proce...
asked by 27.07.2017 / 18:30