Converting DateTime.Now.Ticks.ToString("x"); back to human readable timestamp [duplicate] - c#

This question already has answers here:
How can I convert ticks to a date format?
(4 answers)
Convert integer to hexadecimal and back again
(11 answers)
Closed 2 years ago.
I have a script that creates data and stores the with a name that contains the output of DateTime.Now.Ticks.ToString("x"); I now need to convert this value back to a human readable time in order to figure out when the data was generated for a report but I cant find any tools or equations to do this anywhere. All help appreciated.
some values i'm trying to convert:
8d84e63114d60d2
8d84e6645daa831
8d84e67c9ba1367
8d84e6993166d49

Related

How to write a number in type float? [duplicate]

This question already has answers here:
How do I convert an array of floats to a byte[] and back?
(4 answers)
Closed 9 months ago.
I have the following problem to solve in C#:
Write a number such as 1066018.050 in type float,
the result should be in binary or hexadecimal format.
My question is what are the correct steps I need to follow in order to solve this problem?
You can use BitConverter.GetBytes(float).
float a = (1066018.050F);
var b = BitConverter.GetBytes(a);

I have a Textbox.Text which content is 1+1. How to I convert this into double and store it in i? [duplicate]

This question already has answers here:
Is there a string math evaluator in .NET?
(18 answers)
operators as strings
(13 answers)
Closed 3 years ago.
I have
i = double.Parse(TextBox.Text);
but when I enter the + symbol, this error appear "System.FormatException: 'Input string was not in a correct format.'"
If I understand correctly, you have a much larger issue than you think.
Your textbox has a string. In this case, "1+1" is the value in your textbox. However, that cannot be parsed to an integer value because it contains the plus sign. The plus sign is a character, it is not an integer (0,1,2,3,4..). So, what you get is a data type conversion conflict.
From what I gather, you'd like to evaluate that expression and then store the value into into the i variable. In this case, you would like i to equal 2.
You will need to evaluate the string and convert it into a formula then use the result to store in the variable.
Here's a link to an example of a conversion formula.
https://social.msdn.microsoft.com/Forums/vstudio/en-US/7f62b87d-a35c-4074-a0f0-84a9dd7ff0a5/convert-string-to-formula?forum=csharpgeneral

How to get information of a Byte in a binary format [duplicate]

This question already has answers here:
String to Binary in C#
(4 answers)
Closed 3 years ago.
I want to have my results in this part of code in a binary format rather than in a hexadecimal!!! How can I do it?????
string temp = Byte Format.To Hex(result.Data, "", "");
I mean I want to see my results in (0011010...) rather than being converted to a hexadecimal number.
Thanks for you answers in advance.
Convert.ToString() should do the job. See Documentation
If you have a single byte it will cast to an int
Convert.ToString((int)yourByte, 2); will convert it to base 2 (binary).
string temp = Convert.ToString(bytes, "X"); //X means hexadecimal

Calculating the average of different dates in different years [duplicate]

This question already has answers here:
How to find an average date/time in the array of DateTime values
(7 answers)
Closed 8 years ago.
I need to calculate the average the following observed dates:
1/7/2010
15/7/2011
17/6/2012
3/7/2013
How can I do that in asp.net or any other language. If there is any formula to do that.
You need to convert it to Ticks (this will convert it to System.Int64) and then do the average of them all.
See the following answer: https://stackoverflow.com/a/16683441/643761

C# Double.ToString() [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Custom numeric format string to always display the sign
To format a double to certain precision in C# I write this:
d.ToString("#0.00");
What if I want to force a the sign to appear..
e.g
+2.54 and -2.54
Hope this will work.
YourDoublenumber.ToString("+#;#");

Categories

Resources