473,809 Members | 2,701 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Use flags enum as replacement for missing c# 'in'-operator

1 New Member
This is actually an answer to an old post which is closed. But it may nevertheless be useful to someone.

Old Post: Has if () syntax of C# no IN operator like Pascal or SQL (IN, LIKE,BETWEEN)?

Good, short and fast possibility is to define the enum as flags, like e.g.:

Expand|Select|Wrap|Line Numbers
  1. [Flags]
  2. internal enum TokenType
  3. {
  4.     Empty = 0,
  5.     LBrace = 1,
  6.     PlusLBrace = 2,
  7.     RBrace = 4,
  8.     LBracket = 8,
  9.     RBracket = 16,
  10.     Period = 32,
  11.     RecordID = 64,
  12.     Rubbish = 128,
  13.  
  14.     TermStartSymbols = RecordID | LBrace | PlusLBrace | LBracket 
  15. }
You can then test for a flag like this:

Expand|Select|Wrap|Line Numbers
  1. while ((CurrentToken.Type & TokenType.TermStartSymbols) != TokenType.Empty) {
  2.     sequence.Add(Term());
  3. }
Note that TokenType.Empty must be defined as 0.
Mar 23 '11 #1
0 1212

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

Similar topics

3
17820
by: threepins | last post by:
Hi, Trying the following ... function getCurrentVal(poValue) { var lcCurrentVal = 0; if (isNaN(parseInt(poValue))) { var loValue = poValue.toUpperCase();
5
5103
by: Woon Kiat | last post by:
Hi, Using IDL, I can declare my enumeration like following, library MyAppLib { importlib("stdole32.tlb"); importlib("stdole2.tlb"); typedef enum MyColor
13
1548
by: tmartsum | last post by:
I am not an expert on C++(/C), but also not a complete beginner. I was writing a faster cos (and sin) approximation based on precalculated data (with some success) when I discovered that going from double to int is quite expensive, so maybe a cos/sin approximation without precalculation would be better (faster). Nevertheless I (still) needed to find out where on the unit-cirkle the angle (a double (v) from 0 to 2PI) was. And I looked...
8
2241
by: Craig Klementowski | last post by:
All, I've installed the VS 2005 Beta 1 and was trying to build our current product. I get a compile error when enum value is specified with classname::enumname::enumvalue. Seems the compiler does not want the enumname there anymore. This was not a problem with any previous versions of VS. I could not find any help in any of my programming books or in MSDN. Can anyone explain the reasons to me? Is this behavior to stay? class...
7
2851
by: Inga2005 | last post by:
I have developed an web site in VS2005 but I can't build a release version since the option is missing in the configuration manager. The second thing is that there isn't a bin folder placed in my project. Anybody knows how to solve this.
2
1380
by: fritz-bayer | last post by:
Hi, in a shell script of mine I'm executing a mysql SELECT in batch mode. I want to use the return value for other sql statements. The problem I'm facing is that the tabs, which seperate the columns from each other, are missing in the output. What am I doing wrong?
12
6724
by: Cmtk Software | last post by:
I'm trying to define an enum which will be used from unmanaged c++, C++/CLI managed c++ and from C#. I defined the following enum in a VS dll project set to be compiled with the /clr switch: public enum Days { Sunday };
18
2466
by: Vic Spainhower | last post by:
Hello, Can someone tell me why on some computers the following list will fail . I have a user reported that some of the links in the below list will fail and some will work. The ones that fail will have the www missing in the URL. For example when this particular computer will have the link as http://mysite.com/entry_page.php instead of http://www.mysite.com/entry_page.php This is only happening on 1 computer as far as I know and I...
1
7406
by: Francesco Moi | last post by:
Hi. I get this error message on my Firefox Error Console: ---------------- Error: missing } in XML expression Source File: http://www.foo.com/js/maps.js Line: 273, Column: 18 Source Code: options2 = { title: "John was here", icon: icon1}; -----------------
1
8261
by: oracle newbie | last post by:
select student,trunc(hour,'mm') as period,sum(attempts) as attemptsfrom library_website_users a join library_website_stats b using (student_id)where trunc(hour,'yyyy') = trunc(to_date(:year_selected,'yyyy'),'yyyy')group by student,trunc(hour,'mm')order by trunc(hour,'mm'),student When I run the above the coding on SQL Developer it gave me a error: SQL Error: Missing IN or OUT parameter at index:: 1 Can anyone help me on this problem?...
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9602
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10639
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10120
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7661
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.