If statement with &

Posted on 2007-08-09
Last Modified: 2013-11-05
this is a stupid question but not sure why I get this error

 if ((objCont.Cancelcr == objCot.Tetor) & (objContract.Canctor != objContract.Mor))
{ something

error: invalid expression term >
Question by:dba123
    LVL 142

    Accepted Solution

    if ((objCont.Cancelcr == objCot.Tetor) && (objContract.Canctor != objContract.Mor))
    { something

    LVL 6

    Expert Comment

    Are you sure that all objects (or there properties) are of the same type? If not, the == operator will not work and you will get the invalid expression message.

    the && operator is the same than &, but in case the first expression is false, the execution of the second expression will be skipped.

    Expert Comment

    & is a bitwise AND

    I think you mean to use && which means if( this and this )

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Article by: Najam
    Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now