Results 1 to 3 of 3

Thread: Cannot implicitly convert type 'char' to 'bool'

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Posts
    31

    Cannot implicitly convert type 'char' to 'bool'

    I have the following code:

    Code:
    if (e.KeyChar = (char)13)
        {
            SomeFunction(params);
        }
    When the program complies I get the following error:

    (231): Cannot implicitly convert type 'char' to 'bool'
    Any ideas why that might be? The code is in the following function:

    Code:
    private void nudWidth_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
    which is a Numeric UpDown control.

    Dan

  2. #2
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: Cannot implicitly convert type 'char' to 'bool'

    try
    Code:
     if (e.KeyChar == (char)13)
    Because you are not comparing the values with =

    Hope that helps

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Posts
    31

    Re: Cannot implicitly convert type 'char' to 'bool'

    Haha... yeah, that's it. Thanks.

    Dan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width