Visual C++ .NET/Data Type/boolean
Содержание
Boolean Fundamental Type in Action
<source lang="csharp">
- include "stdafx.h"
using namespace System;
void main() {
bool a = 18757; // will give a warning but set to true bool b = 0; // false bool c = true; // obviously true bool d = false; // obviously false Console::WriteLine( a ); Console::WriteLine( b ); Console::WriteLine( c ); Console::WriteLine( d );
}
</source>
Boolean Literal and casting
<source lang="csharp">
- include "stdafx.h"
- using <mscorlib.dll>
using namespace System; Int32 main(void) {
Boolean a = 18757; // will give a warning but set to true Boolean b = 0; // false Boolean c = true; Boolean d = false; Console::WriteLine( a ); Console::WriteLine( b ); Console::WriteLine( c ); Console::WriteLine( d ); return 0;
}
</source>
Boolean Literal and toString
<source lang="csharp">
- include "stdafx.h"
- using <mscorlib.dll>
using namespace System; Int32 main(void) {
// This is kind of neat. Boolean literals are objects too! Console::WriteLine ( true.ToString () ); Console::WriteLine ( false.ToString () ); return 0;
}
</source>
Boolean literals are objects too
<source lang="csharp">
- include "stdafx.h"
using namespace System; void main() {
Console::WriteLine ( true.ToString () ); Console::WriteLine ( false.ToString () );
}
</source>
Boolean Literals in Action
<source lang="csharp">
- include "stdafx.h"
using namespace System; void main() {
bool isTrue = true; bool isFalse = false; Console::WriteLine ( isTrue ); Console::WriteLine ( isFalse );
}
</source>