Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.0
What is the difference between bool and Boolean in c#?
.
can we use new with Boolean?
 
bool B=true;
Console.WRILTElINE("tHE BOOL VALUE IS{0}:",B);
so it is display <b>True</b> why?
Posted 18-Apr-10 20:43pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

bool is an alias for System.Boolean just as int is an alias for System.Int32. See here[^]. To check a full list of aliases see here[^].
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Hello,
Boolean is a datatype that will return u only two values either true or false the code which you have displayed will defiantely return a true value because u have declared a Boolean value named B and initialized a value true to it and displayed b if u wana try some examples with boolean then my friend heres the right code for you
 
using System;
using System.Collections.Generic;
using System.Text;
 
namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            bool b = true;
 
            int a = 10;
            if (a < 1)
            {
                Console.WriteLine("value of b is :"+b);
            }
            else
            {
                b = false;
                Console.WriteLine("value of b is :" + b);
            }
        }
    }
}
 
just try changing value for integer variable "a" and u will see the trick...
Now coming to the first part of your question thats difference between bool and Boolean
 
my friend bool is an alias for System.Boolean jsut like int is an alias for System.Int32 thats it Smile | :)
 
please do rate my answer once u find it useful
 
Thanks & Regards
Radix Rose | [Rose]
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

There is NO difference whatsoever.
You may use either bool or Boolean with exactly the same results.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi
 
The difference between bool and Boolean is as follows
 
bool is basic data type and Boolean is an object type
 
Boolean is an class which wraps the bool type because in the object oriented technology,we have to represent in the form of classes and object so that for every data type we have an class type.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 6,569
1 Sergey Alexandrovich Kryukov 6,168
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 19 Apr 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100