Possible Duplicate:
Help converting type - cannot implicitly convert type ‘string’ to ‘bool’nie można niejawnie przekonwertować typu „int” do „bool”
jestem bardzo nowy w języku n nie jestem dobrym programistą. Ten kod powoduje błąd:
cannot implicitly convert type int to bool.
Nie jestem pewien, co robię źle. Czy ktoś może mi powiedzieć, co robię źle. Jakakolwiek pomoc byłaby doceniona i żadna zalecana pomoc również nie pomogłaby.
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())
{
}
}
}
}
}
Inny typ, ale ten sam pomysł. Zwróć uwagę na * gdzie * jest błąd - poprowadzi cię prosto do problemu. –
gdzie zadeklarowałeś zmienną dla limitOfGuess? – Nich
Ogłosiłem to jako const. Zaraz po deklaracji klasy. – user1730332