473,322 Members | 1,403 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.

is it possible to have IN in a if-statement?

ASP.NET 2.0

This code gives me compile error:
if (menuitem.Text in {"Inbox", "Outbox" })
{
e.Item.Parent.ChildItems.Remove(e.Item);
}

Instead I could just have written the code below, but I think maybe using IN
is better..
if (menuitem.Text == "Inbox" || menuitem.Text == "Outbox" )
{
e.Item.Parent.ChildItems.Remove(e.Item);
}

Any suggestions on how to use IN in the if-statement above? is it possible?

Jeff
Feb 25 '07 #1
4 932
"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:OH**************@TK2MSFTNGP03.phx.gbl...
but I think maybe using IN is better..
Maybe so, but not much use as it won't work...
is it possible?
No.
Feb 25 '07 #2
Jeff,
I suspect that you are thinking of the SQL "IN" Keyword, which is simply not
present in this form in the C# language.

if you have a large number of items, you could put them into one of the
collections or System.Collections.Generic classes and use one of the methods
like Find or Contains on it.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Jeff" wrote:
ASP.NET 2.0

This code gives me compile error:
if (menuitem.Text in {"Inbox", "Outbox" })
{
e.Item.Parent.ChildItems.Remove(e.Item);
}

Instead I could just have written the code below, but I think maybe using IN
is better..
if (menuitem.Text == "Inbox" || menuitem.Text == "Outbox" )
{
e.Item.Parent.ChildItems.Remove(e.Item);
}

Any suggestions on how to use IN in the if-statement above? is it possible?

Jeff
Feb 25 '07 #3
Yes, I was thinking about IN as in sql/select... anyway I have solved it now
by using:

if (menuitem.Text == "Inbox" || menuitem.Text == "Outbox" )
{
e.Item.Parent.ChildItems.Remove(e.Item);
}

"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in
message news:27**********************************@microsof t.com...
Jeff,
I suspect that you are thinking of the SQL "IN" Keyword, which is simply
not
present in this form in the C# language.

if you have a large number of items, you could put them into one of the
collections or System.Collections.Generic classes and use one of the
methods
like Find or Contains on it.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Jeff" wrote:
>ASP.NET 2.0

This code gives me compile error:
if (menuitem.Text in {"Inbox", "Outbox" })
{
e.Item.Parent.ChildItems.Remove(e.Item);
}

Instead I could just have written the code below, but I think maybe using
IN
is better..
if (menuitem.Text == "Inbox" || menuitem.Text == "Outbox" )
{
e.Item.Parent.ChildItems.Remove(e.Item);
}

Any suggestions on how to use IN in the if-statement above? is it
possible?

Jeff

Feb 25 '07 #4
switch (menuitem.Text) {
case "Inbox":
case "Outbox":
e.Item.Parent.ChildItems.Remove(e.Item);
break;
case "abc":
case "xyz":
// other options here
break;
}

"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:OH**************@TK2MSFTNGP03.phx.gbl...
ASP.NET 2.0

This code gives me compile error:
if (menuitem.Text in {"Inbox", "Outbox" })
{
e.Item.Parent.ChildItems.Remove(e.Item);
}

Instead I could just have written the code below, but I think maybe using
IN is better..
if (menuitem.Text == "Inbox" || menuitem.Text == "Outbox" )
{
e.Item.Parent.ChildItems.Remove(e.Item);
}

Any suggestions on how to use IN in the if-statement above? is it
possible?

Jeff

Feb 25 '07 #5

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

Similar topics

4
by: Julia Briggs | last post by:
I am struggling to create a PHP function that would take a specified image (JPG, GIF or PNG) from a link, and resize it down to a thumbnail so it will always fit in a 200x250 space. I am hoping...
20
by: CHIN | last post by:
Hi all.. here s my problem ( maybe some of you saw me on other groups, but i cant find the solution !! ) I have to upload a file to an external site, so, i made a .vbs file , that logins to...
3
by: Jonathan | last post by:
Hi all! For a match schedule I would like to find all possible combinations of teams playing home and away (without teams playing to themselves of course). I now the simple version works...
4
by: TGOS | last post by:
I was thinking about it for a while, a mutex written in C and without disabling any interrupts. Is it possible? typdef struct mutex { unsigned int owner1; unsigend int owner2; } *mutex; ...
5
by: steve Sweales | last post by:
I am trying to design a windows forms application (not asp.net) in C#, and need to know if the following scenario is possible : Once my application is running I need to be able to impersonate...
2
by: Bhupesh Naik | last post by:
This is a query regarding my problem to make a spell and grammar check possible in text area of a web page. We have aspx pages which are used to construct letters. The browser based screens...
8
by: Mir Nazim | last post by:
Hello, I need to write scripts in which I need to generate all posible unique combinations of an integer list. Lists are a minimum 12 elements in size with very large number of possible...
17
by: binjobster | last post by:
Hello everyone, I'm updating some documents that describes so many C/C++ functions/method(about 2500). But I'm not familiar with these codes. So I want to find such a utility can generate...
1
by: AAA | last post by:
hi, I'll explain fastly the program that i'm doing.. the computer asks me to enter the cardinal of a set X ( called "dimX" type integer)where X is a table of one dimension and then to fill it...
7
by: Robert S. | last post by:
Searching some time now for documents on this but still did not find anything about it: Is it possible to replace the entry screen of MS Office Access 2007 - that one presenting that default...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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...
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.