473,398 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

I need some help with a C# if/then statement

For some reason I keep getting this error: Operator '&&' cannot be applied to operands of type 'bool' and 'int' When I try to run this if then statement:

if (majorOutages <= 3 && dTimePercentage = 6) flmajorOutages = 6;
if (majorOutages <= 3 && dTimePercentage = 5) flmajorOutages = 5;
if (majorOutages <= 3 && dTimePercentage = 4) flmajorOutages = 4;
if (majorOutages <= 3 && dTimePercentage = 3) flmajorOutages = 3;
if (majorOutages <= 3 && dTimePercentage = 2) flmajorOutages = 2;

Any ideas why? If you need any more of my code, let me know! Thanks!
Mar 20 '08 #1
3 942
Plater
7,872 Expert 4TB
Equels comparison is done with ==
Expand|Select|Wrap|Line Numbers
  1. if (majorOutages <= 3 && dTimePercentage == 6) flmajorOutages = 6;
  2. if (majorOutages <= 3 && dTimePercentage == 5) flmajorOutages = 5;
  3. if (majorOutages <= 3 && dTimePercentage == 4) flmajorOutages = 4;
  4. if (majorOutages <= 3 && dTimePercentage == 3) flmajorOutages = 3;
  5. if (majorOutages <= 3 && dTimePercentage == 2) flmajorOutages = 2;
  6.  
Mar 20 '08 #2
Sick0Fant
121 100+
Also, do yourself a favor next time and use a switch
Mar 20 '08 #3
Thanks! I am a newbie to c#. I actually am using a switch. Maybe I am going about this the wrong way?? here is the full code:

Expand|Select|Wrap|Line Numbers
  1. //check how many outages and calculate with downtime percentage
  2.         switch (Convert.ToInt32(flmajorOutages))
  3.         {
  4.             case 1:
  5.                 dTimePercentage = 1;                
  6.                 break;
  7.             case 2:
  8.                 dTimePercentage = 1;               
  9.                 break;
  10.             case 3:
  11.                 dTimePercentage = 2;
  12.                 break;
  13.             case 4:
  14.                 dTimePercentage = 3;                
  15.                 break;
  16.             case 5:
  17.                 dTimePercentage = 4;               
  18.                 break;
  19.             case 6:
  20.                 dTimePercentage = 5;                
  21.                 break;
  22.             case 7:
  23.                 dTimePercentage = 6;
  24.                 break;
  25.             default:
  26.                 dTimePercentage = 6;
  27.                 break;
  28.         }
  29.  
  30.         if (majorOutages >= 8) flmajorOutages = 6;
  31.         if (majorOutages <= 7) flmajorOutages = 5;
  32.         if (majorOutages <= 5) flmajorOutages = 4;
  33.         if (majorOutages <= 3 && dTimePercentage = 6) flmajorOutages = 6;
  34.         if (majorOutages <= 3 && dTimePercentage = 5) flmajorOutages = 5;
  35.         if (majorOutages <= 3 && dTimePercentage = 4) flmajorOutages = 4;
  36.         if (majorOutages <= 3 && dTimePercentage = 3) flmajorOutages = 3;
  37.         if (majorOutages <= 3 && dTimePercentage = 2) flmajorOutages = 2;
  38.  
  39.         string BusEffFactorGraph;
  40.         string networkScore;
  41.         switch (flmajorOutages)
  42.         {
  43.             case 1:
  44.                 BusEffFactorGraph = "66";
  45.                 networkScore = "Above Average";
  46.                 break;
  47.             case 2:
  48.                 BusEffFactorGraph = "66";
  49.                 networkScore = "Above Average";
  50.                 break;
  51.             case 3:
  52.                 BusEffFactorGraph = "99";
  53.                 networkScore = "Average";
  54.                 break;
  55.             case 4:
  56.                 BusEffFactorGraph = "133";
  57.                 networkScore = "Below Average";
  58.                 break;
  59.             case 5:
  60.                 BusEffFactorGraph = "166";
  61.                 networkScore = "Poor";
  62.                 break;
  63.             case 6:
  64.                 BusEffFactorGraph = "200";
  65.                 networkScore = "Failing";
  66.                 break;
  67.             case 7:
  68.                 BusEffFactorGraph = "220";
  69.                 networkScore = "Failing";
  70.                 break;
  71.             case 8:
  72.                 BusEffFactorGraph = "250";
  73.                 networkScore = "Failing";
  74.                 break;
  75.             default:
  76.                 BusEffFactorGraph = "250";
  77.                 networkScore = "Failing";
  78.                 break;
  79.         }
I am just tweaking that was already written before I was here so the second switch was already in place and I had to add the first switch... Any help is greatly appreciated! Thank you!
Mar 20 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

45
by: Joh | last post by:
hello, i'm trying to understand how i could build following consecutive sets from a root one using generator : l = would like to produce : , , , ,
1
by: Tom Rahav | last post by:
Hello all! I develop application in Visual Basic .NET and ORACLE database. My question is how do I "send" script file to the database using visual basic .net. Other words, is there any way to...
3
by: luna | last post by:
theres no errors in my code - but it does nothing at all - its supposed to be populating text boxes!! any ideas ? (im am pretty new to all this) If Not Page.IsPostBack Then Dim search As...
7
by: Buck Rogers | last post by:
Hi all! Newbie here. Below is an example from Teach Yourself C in 21 Days. My apologies if it is a bit long. What I don't understand is how the "get_data" function can call the...
2
by: clinttoris | last post by:
Hello, If someone could help me it would be appreciated as I am not having much luck. I'm struggling with my asp code and have some questions relating to asp and oracle database. First...
22
by: the_grove_man | last post by:
I purchased a book titled "Pro ASP.NET 2.0" to get up to speed on web stuff because I ususally do Windows Form Applications.. But in the first chapters I was reading this week it brought to mind...
2
by: JRamirez | last post by:
Need help cannot figure out where I made the error. -------------------------------------------------------------------------------- Can someone view what I have, I need help I cannot figure out...
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
1
by: darrel | last post by:
Hi vb master i need help on this here my code: If Combo1(0) = rs.Fields("TimeStart") And Combo4(0) = rs.Fields("TimeEnd") And Combo2(0) = rs.Fields("ROOM") And Combo3(0) = rs.Fields("DAYS")...
6
by: zaina | last post by:
hi everybody i am nwebie in this forum but i think it is useful for me and the member are helpful my project is about connecting client with the server to start exchanging messages between...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.