Click here to Skip to main content
15,918,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello guys, I have following function in java script that I want to convert to c# code. Can some one let me know this code in c# thanks
JavaScript
Block.prototype.add = function(value)
  {
    var key = value.toSource();
    var pos = this.search(key);
    if (this.keys[pos] != key)
      {
        this.keys.splice(pos, 0, key);
        this.items.splice(pos, 0, value);
      }
  }
Posted
Updated 19-Feb-22 1:55am
v2

function football (arg1, arg2){

let tshirtPrice = Number(arg1);

let sum = Number(arg2);

let shortsPrice = tshirtPrice * 0.75;

let socksPrice = shortsPrice * 0.20;

let shoesPrice = (tshirtPrice + shortsPrice)* 2;



let totalPrice = (tshirtPrice + shortsPrice + socksPrice + shoesPrice);

let discout = totalPrice * 0.15;

let discountedPrice = (totalPrice - discout);

let moneyNeeded = (sum - discountedPrice).toFixed(2);



if (discountedPrice >= sum){

console.log ("Yes, he will earn the world-cup replica ball!");

console.log (`His sum is ${(discountedPrice).toFixed(2)} lv.`);

} else {

console.log("No, he will not earn the world-cup replica ball.");

console.log (`He needs ${moneyNeeded} lv. more.`);

}



}
 
Share this answer
 
Comments
Dave Kreskowiak 19-Feb-22 11:01am    
This is not a code conversion service. The only code you're ever going to get is the code YOU write.
Hi,

Try to use Javascript to C# converter.

hope this will convert

thanks
-amit.
 
Share this answer
 
Comments
EricThe 3-Jan-12 2:07am    
I tried it and it gave me this c# code

Block.prototype.contains = function(value)
{
var key = value.toSource();
var pos = @this.search(key);
return @this.keys[pos] = key;
}

but under the = fucntion it has red line saying method must have a return type.
AmitGajjar 3-Jan-12 3:29am    
replace the first line with your C# function.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900