8

I'm writing a library for personal use that greatly expands C# features, and I was wondering on something quite interesting... Is it possible to create you own keywords? For example, if, foreach, for etc.

The reason I want to do this can be found at my previous question.

Community
  • 1
  • 1
TechnicalTophat
  • 1,655
  • 1
  • 15
  • 37

1 Answers1

31

No, you can not do that. Language keywords are defined in the language definition. You could probably use the open sourced parts (compilers, etc) and create your own version of them.

Thorsten Dittmar
  • 55,956
  • 8
  • 91
  • 139
  • 7
    Why the downvote? The answer is correct! There's no way to define your own keywords with standard means. Only if you modify the compiler stages you'd be able to do so, which is exactly what's in the answer to the question this is a duplicate of. – Thorsten Dittmar Jun 08 '16 at 10:05
  • Agreed. This is the correct answer. C# does not allow you to define keywords. – Steve Cooper Jun 08 '16 at 10:10
  • @ThorstenDittmar I upvoted you to restore the universal equilibrium. No it was a great answer. Straight to the point. Not what I wanted to hear but it is indeed correct. – K-Dawg Nov 17 '18 at 22:36