Hi
What is the bool and why are we use in event form?
private bool UploadImage(string UploadPath)
{
bool retVal = true;
string strFileName;
string strFilePath;
string strType;
string strFolder = UploadPath; //save it here
string err = "";
string ext = "";
Loading
Prabhu RajaPosted Nov 25, 2011, 2:59 AM
int i =1; // integer variable
if(i > 0) // Here bool is used indirectly
{
}
bool isSuccess = true; // bool variable
if(isSuccess==false) // Here bool is used in both directly and indirectly
{
}
bool is used in many ways, to check condition, to verify the process is completed or not, validations etc.
bool is used in most of all places not only in events.
The Wikipedia described boolean data type in details.
http://en.wikipedia.org/wiki/Boolean_data_type
you can also use MSDN to know more about bool,
http://msdn.microsoft.com/en-us/library/c8f5xwh7(v=vs.71).aspx
Karthik AgarwalPosted Nov 25, 2011, 1:34 AM
private bool UploadImage(string UploadPath)
says that the function's return type is boolean type which means it sends either true or false to the function which called it.
And when it comes to the next place where you used bool in your code
bool retVal = true;
here you are making the bool variable as true i am not wrong at the end of the function you would have returned that to the calling function as follows:
return retValue; which sends true to the calling function. Which in turn means that the operation you intend to do in this function is done or succeeded.
Satyapriya NayakPosted Nov 24, 2011, 11:17 PM
bool is used to declare variables to store the Boolean values, true and false.
Refer
http://www.dotnetperls.com/bool
Thanks