Possible Duplicate:
Help converting type - cannot implicitly convert type ‘string’ to ‘bool’No se puede convertir implícitamente el tipo 'int' a 'bool'
soy muy nuevo en el idioma n no soy un buen programador. Este código me da error:
cannot implicitly convert type int to bool.
No estoy seguro de lo que estoy haciendo mal. ¿Pueden algunos decirme lo que estoy haciendo mal? Cualquier ayuda sería apreciada y cualquier recomendación también ayudaría.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class mysteryVal
{
public const int limitOfGuess = 5;
// Data member
public int mystVal;
private int numOfGuess ;
private randomNumberMagnifier mag = new randomNumberMagnifier();
public int randomMag(int num)
{
return num + mystVal;
}
// Instance Constructor
public mysteryVal()
{
mystVal = 0;
numOfGuess = 0;
}
public void game(int user)
{
int userInput = user;
if (numOfGuess < limitOfGuess)
{
numOfGuess++;
if (userInput = mag.randomMagnifier())
{
}
}
}
}
}
Diferente tipo, pero la misma idea. Preste atención a * donde * el error es - lo guiará directamente al problema. –
donde declaraste la variable para limitOfGuess? – Nich
Lo declare como una const. Justo después de la declaración de la clase. – user1730332