bool value to string

In this chapter you will learn:

  1. Using ToString() to Convert to a string
  2. Convert boolean value to "Yes" or "No"

Using ToString() to Convert to a string

class MainClass/* j  a  v a2 s. c  o m*/
{
  static void Main()
  {

    bool boolean = true;
    string text = boolean.ToString();
    // Display "True"
    System.Console.WriteLine(text);

  }
}

Convert boolean value to "Yes" or "No"

using System;/*from ja  v  a  2  s. com*/

public class Main
{
    public static string ConvertBoolToYesNo(bool b)
    {
        if (b) { return "Yes"; }

        return "No";
    }
}

Next chapter...

What you will learn in the next chapter:

  1. Converts string to Boolean, throws an exception if not compatible
Home » C# Tutorial » bool, char
bool
bool and if statement
bool value to string
Parse string to bool value
char type
char escape sequence
char case
Compare char value
char min/max value
Is char a digit
Is char a letter
Is char a symbol
Is char a Separator
Is char white space
Convert to char
UTF-16 Character