0
I have the following condition in C++ and would like to move to C#. The problem I’m having is with the function div
error:
The name 'div' does not exist in the Current context
if (quant > 0)
{
return div(quant, 7).quot;
}
0
I have the following condition in C++ and would like to move to C#. The problem I’m having is with the function div
error:
The name 'div' does not exist in the Current context
if (quant > 0)
{
return div(quant, 7).quot;
}
4
From what I understand you want to do a split and take only the quotient. If this is it I see no reason to use the function div
not even on C++. The same goes for C#. Actually C# doesn’t even have a similar function ready (the advantage of this function is to return both the quotient and the rest) so you have an error trying to use it.
So in C# you just need to do a simple split with the division operator. Your code would look like this:
if (quant > 0)
{
return quant / 7;
}
Browser other questions tagged c# c++ mathematics operators
You are not signed in. Login or sign up in order to post.
What’s wrong with the
div
?– Vinícius Gobbo A. de Oliveira
Put more information on the question and clarify your doubt and the problem. Cite examples of other attempts you made.
– Jones
the div is underlined red with the following message: The name 'div' does not exist in the Current context
– user2254936
Because you need to use the
div
in C++? I provided an answer that gives you the same result in C#. Of course the problem could even be another. From the code section, not to determine this. If the problem is another, you can [Dit] your question to put the most complete code and information to help understand your problem.– Maniero
@user2254936 Take a look at [tour]. You can accept an answer if it solved your problem. You can vote for all the posts on the site as well. Did any help you more? You need something to be improved?
– Maniero