Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
This post was edited and submitted for review last year and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I'm looking for an answer to the following:
Desired behaviour
Round the mathematical constant pi to 2 or 4 decimals.
Current code
I have tried the following:
Double piRounded;
piRounded = Math.Round.PI(4);
piRounded = Math.Round.PI(2);
Current result
This results in the following error:
'System.Math.Round(double)' is a 'method', which is not valid in the given context
Math.Round in your code is being specified as a property, not a method invocation.
Place your parameters in the round function like Math.Round(...) - You will want to pass in the PI constant.
Math.Round(Math.PI, 4) (as stated in comments).
Use:
Math.Round(Math.PI, 2);
and
Math.Round(Math.PI, 4);
respectively
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
[how to call an integer as it is changing when loop is running i want print and calculate every single time loop runs hope you understand my question
You need to change the line
total = perunit * quanitity
to
total += perunit * quantity
this will add the result to total, not override total every time.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I have a database field called "PIECE" which datatype is NUMERIC(11,0),
I must convert this field to a long-datatype.
This without any luck or succes, I'll keep getting the same error:
Wrong conversion...
I tried the next things:
(long)PIECE
long.Parse(PIECE.ToString().Trim())
But I'm still having the wrong conversion message,
is here someone who can help me?
This will do it:
var result = Convert.ToInt64(PIECE);
https://msdn.microsoft.com/en-us/library/0zahhahw(v=vs.110).aspx
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
Found this csv parser: https://github.com/bytefish/TinyCsvParser
Following his example but I even added one int property.
By setting a negative value to that int, it gave me one unvalid row.
Couldn't find any solution for this simple? problem.
The type converter was using the wrong NumberStyle as default. I have fixed the problem and added a Test case to the project: https://github.com/bytefish/TinyCsvParser/issues/2.
You could also instantiate a custom converter with the right NumberStyle (see WithCustomConverter, Example), but I suggest simply updating to the latest version (0.6), which is also updated in NuGet.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
Below are the test input . The result I want is AAA- and AB-- respectively. The input string has no specific pattern. So first occurrence of / and the 4 character before that is the result I want to have.
Test line abc (r);AAA-/2010/001
Test line abc (r);AB--/2010/001
Like that? (EDIT: in .NET regex patterns, / does not need escaping)
(.{4})/
Consider sites like https://regex101.com for future needs)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
When we call/paste "GetAsyncKeyState(Keys.F4)" into the watch window in VS2013 during a debugging session it returns 204996608. I looked at the MSDN documentation but I can't figure out how to understand that number. What is it trying to tell me?
From http://msdn.microsoft.com/en-us/library/windows/desktop/ms646293(v=vs.85).aspx:
If the function succeeds, the return value specifies whether the key
was pressed since the last call to GetAsyncKeyState, and whether the
key is currently up or down. If the most significant bit is set, the
key is down, and if the least significant bit is set, the key was
pressed after the previous call to GetAsyncKeyState. However, you
should not rely on this last behavior; for more information, see the
Remarks.
Which means you need to check the most significant bit to see if the key was pressed:
bool f4Pressed = (GetAsyncKeyState(Keys.F4) & (1 << 15)) != 0;
GAKS returns a short int, ie. 16-bit integer, with the MSB set or not.
So, just get your return type correct and then test if it's negative.