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

C# keyword list programatically

Hello,

Could someone please tell me how I can get a list of c# keywords (e.g.
'event') programmatically at runtime?

Many thanks,

Ronnie
Oct 30 '07 #1
8 7998
Ronnie Smith <sm**********@newsgroup.nospamwrote:
Could someone please tell me how I can get a list of c# keywords (e.g.
'event') programmatically at runtime?
Well, only by having a hard-coded list of them. They're not exposed by
anything in the framework as far as I'm aware.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 30 '07 #2
Hello Ronnie,

there is no way for this, they are hard-codded.

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
RSHello,
RS>
RSCould someone please tell me how I can get a list of c# keywords
RS(e.g. 'event') programmatically at runtime?
RS>
RSMany thanks,
RS>
RSRonnie
RS>
Oct 30 '07 #3
Thanks for the reply Jon. I was hoping that there would be a framework
solution since my hardcoded list may no longer be complete at the next .NET
release.

OK - I'll work with the hardcoded list.

Ronnie

"Jon Skeet [C# MVP]" wrote:
Ronnie Smith <sm**********@newsgroup.nospamwrote:
Could someone please tell me how I can get a list of c# keywords (e.g.
'event') programmatically at runtime?

Well, only by having a hard-coded list of them. They're not exposed by
anything in the framework as far as I'm aware.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 30 '07 #4
Ronnie Smith <sm**********@newsgroup.nospamwrote:
Thanks for the reply Jon. I was hoping that there would be a framework
solution since my hardcoded list may no longer be complete at the next .NET
release.

OK - I'll work with the hardcoded list.
Well, C# 3 is about to come out but I wouldn't expect C# 4 any time
soon, and the C# 3 spec is nailed down now.

There are various *contextual* keywords in C# 3, but no new "real"
keywords as such. What are you wanting to do with the keywords? If it's
something like syntax highlighting, it's worth using the contextual
keywords.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 30 '07 #5
Ronnie Smith kirjoitti:
Thanks for the reply Jon. I was hoping that there would be a framework
solution since my hardcoded list may no longer be complete at the next .NET
release.
Why do you need the list? If you are afraid of using keywords in your
code, you can protect them with @ sign, like:

using System;
namespace Keyword{
class Program{
static void Main(string[] args) {
int @int = 2;
int @foo = 4;
Console.WriteLine("values {0} {1}", @int, @foo);
}
}
}

So, you can protect keywords with @, but it does not matter in front of
non keyword.

--
Arto Viitanen
Oct 31 '07 #6
Arto,

I have a tool which can load a c/c++ header file and automatically create a
c# wrapper for the corresponding DLL - allowing the old style DLL to be
accessed from .NET. However sometimes the parameters names are actually c#
keywords. Yes, I could add an underscore or the '@' symbol before each one,
but I thought that the cleaner way would be to preserve the original
parameter names where possible and only ammend them if needed. Hence my
request to programmatically ascertain the c# keywords.

Ronnie

"Arto Viitanen" wrote:
Ronnie Smith kirjoitti:
Thanks for the reply Jon. I was hoping that there would be a framework
solution since my hardcoded list may no longer be complete at the next .NET
release.

Why do you need the list? If you are afraid of using keywords in your
code, you can protect them with @ sign, like:

using System;
namespace Keyword{
class Program{
static void Main(string[] args) {
int @int = 2;
int @foo = 4;
Console.WriteLine("values {0} {1}", @int, @foo);
}
}
}

So, you can protect keywords with @, but it does not matter in front of
non keyword.

--
Arto Viitanen
Oct 31 '07 #7
Hi Ronnie,

Thanks for your background information.

The C# language keywords are part of the C# language specification which is
not defined in the .Net Framework(which can target many other languages).
Actually, the CLI will have no knowledge of these C# language keywords.
These C# keywords are built in the C# compiler not the .Net Framework.
Also, certain C# compiler vendor may add its own standard C# language
extension keywords.

So I think you have to build a hard-list for the C# keywords. Hope this
helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Nov 1 '07 #8
Hi Jeffrey,

Thanks for taking the time to explain the issue to me.

Best regards,

Ronnie

""Jeffrey Tan[MSFT]"" wrote:
Hi Ronnie,

Thanks for your background information.

The C# language keywords are part of the C# language specification which is
not defined in the .Net Framework(which can target many other languages).
Actually, the CLI will have no knowledge of these C# language keywords.
These C# keywords are built in the C# compiler not the .Net Framework.
Also, certain C# compiler vendor may add its own standard C# language
extension keywords.

So I think you have to build a hard-list for the C# keywords. Hope this
helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Nov 1 '07 #9

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

Similar topics

1
by: svilen | last post by:
hi. this was named but it is misleading. i want to have the order of setting items in intrinsic dicts (keyword args, or class attributes, etc). which is, a prdered dict trhat matches the...
7
by: Peter Otten | last post by:
I'm sure they have been mentioned somewhere but here are some more advantages of a decorator keyword (I use "transform"): - The docstring can be moved to the top of the decorator suite. - Simple...
24
by: Shao Zhang | last post by:
Hi, I am not sure if the virtual keyword for the derived classes are required given that the base class already declares it virtual. class A { public: virtual ~A();
0
by: Perry Shindle | last post by:
Does anyone no where I can get the latest, up-to-date list of valid values for the CLI PATCH2 keyword? I followed the current link in the on-line DB2 UDB Information Center and it led me to PATCH2...
9
by: Tom | last post by:
How do you programatically get a list of subfolders in a folder? Thanks! Tom
3
by: Guadala Harry | last post by:
In the following line of code, what is the point of including the 'new' keyword? List.Changed -= new ChangedEventHandler(ListChanged); I'm just a bit confused because I thought 'new' was used...
54
by: Sahil Malik [MVP] | last post by:
What the heck - I can't find it. A bit shocked to see it missing though. So "Does VB.NET have the yield keyword, or any equivalent of it" ? -- - Sahil Malik Upcoming ADO.NET 2.0 book -...
6
by: tom | last post by:
Hi I try to check whether a given input is keyword or not. However this script won't identify keyword input as a keyword. How should I modify it to make it work? #!usr/bin/env python import...
5
by: kanley | last post by:
I have a main table with a text description field. In this field, its populated with a string of data. I need to identify from this string of data the name of the vendor using some keywords. I...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.