473,322 Members | 1,510 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,322 software developers and data experts.

IF Statements

Hi, I'm still new to C# and haven't been able to find an solution to an IF
statement problem. Is it possible to use an OR condition in an IF statement,
i.e

if (fileExtention == ".tmp" or fileExtention == ".lsi")
{
other statements go here.....
}

Thank you
Nov 17 '05 #1
4 1239
Hi Chuck831!
Hi, I'm still new to C# and haven't been able to find an solution to an IF
statement problem. Is it possible to use an OR condition in an IF statement,
i.e

if (fileExtention == ".tmp" or fileExtention == ".lsi")
{
other statements go here.....
}


Try:

if ( (fileExtention == ".tmp") || (fileExtention == ".lsi")) )
{
// other statements go here.....
}

For AND use "&&"

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Nov 17 '05 #2
John - Thank you

"Jochen Kalmbach [MVP]" wrote:
Hi Chuck831!
Hi, I'm still new to C# and haven't been able to find an solution to an IF
statement problem. Is it possible to use an OR condition in an IF statement,
i.e

if (fileExtention == ".tmp" or fileExtention == ".lsi")
{
other statements go here.....
}


Try:

if ( (fileExtention == ".tmp") || (fileExtention == ".lsi")) )
{
// other statements go here.....
}

For AND use "&&"

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/

Nov 17 '05 #3

"Jochen Kalmbach [MVP]" <no********************@holzma.de> skrev i en
meddelelse news:%2****************@tk2msftngp13.phx.gbl...
Hi Chuck831!
Hi, I'm still new to C# and haven't been able to find an solution to an
IF statement problem. Is it possible to use an OR condition in an IF
statement, i.e if (fileExtention == ".tmp" or fileExtention == ".lsi")
{
other statements go here.....
}


Try:

if ( (fileExtention == ".tmp") || (fileExtention == ".lsi")) )
{
// other statements go here.....
}

For AND use "&&"

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/


and and or are C++ keywords - one of the remaining places where Microsoft
hasn't yet become compatible.

/Peter
Nov 17 '05 #4

"Peter Koch Larsen" <pk*@mailme.dk> skrev i meddelandet
news:OJ**************@TK2MSFTNGP12.phx.gbl...

"Jochen Kalmbach [MVP]" <no********************@holzma.de> skrev i
en meddelelse news:%2****************@tk2msftngp13.phx.gbl...
Hi Chuck831!
Hi, I'm still new to C# and haven't been able to find an solution
to an IF statement problem. Is it possible to use an OR condition
in an IF statement, i.e if (fileExtention == ".tmp" or
fileExtention == ".lsi")
{
other statements go here.....
}


Try:

if ( (fileExtention == ".tmp") || (fileExtention == ".lsi")) )
{
// other statements go here.....
}

For AND use "&&"

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/


and and or are C++ keywords - one of the remaining places where
Microsoft hasn't yet become compatible.


It's an extension *not* to have the keywords. :-)

If you choose Disable Microsoft Extensions, and and or works
according to the standard.
Bo Persson
Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Bart Nessux | last post by:
Should an if statement have a corresponding else statement? Or, is it OK to have an if statement by itself. For completeness, it seems the two should be together, but from experience I know that a...
9
by: Jaime Wyant | last post by:
I know I've seen this somewhere, but can't seem to google it. Is there a way to use an alternate statement separator, other than the default ';'? jw
1
by: Tom D | last post by:
I'm rewriting a database interface that our company currently has. Currently it's using the Pear::DB interface, but we found that that was introducing a bit too much overhead. I'm rewriting the...
39
by: slogging_away | last post by:
Hi - I'm running Python 2.4.2 (#67, Sep 28 2005, 12:41:11) on win32, and have a script that makes numerous checks on text files, (configuration files), so discrepancies can be reported. The script...
0
by: Fuzzyman | last post by:
Hello all, The following is a copy of a blog entry. It's asking a question about future statements and the built in compile function. I'd appreciate any pointers or comments about possible...
20
by: Neroku | last post by:
Hello, i would like to know what the serious definition of statements and expressions is: i know an expression are evaluated to a value, i.e: 1 == 2 5+7 foo( 1,2) and a statement is...
2
by: ojorus | last post by:
Hi! Some questions regarding the mysqli-extension (php5) 1) Prepared statements: If I understand things right, prepared statements will give better performance if you make several similar...
3
by: Dmitri | last post by:
Hello! I have a developer that is playing around with some SQL statements using VB.NET. He has a test table in a SQL 2000 database, and he has about 2000 generated INSERT statements. When the...
0
by: Gary Herron | last post by:
Ohad Frand wrote: There is no way you can consider 'elif', 'else', 'except', and 'from' statements. However, as someone pointed out, the kwlist from the keyword module is the closest thing we...
0
by: Ohad Frand | last post by:
Hi Thanks a lot for your reply I think the main uses for it is to study the language and to see that I didn't miss anything else or that something is changed from one version to another. The...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.