Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When are C# keywords not reserved?

I just found myself absent-mindedly using from as an identifier.

I realise that it is possible to use @ to escape identifier names and as such use reserved words, but I don't understand why in this case I got no warning or error.

I have no desire to use reserved words for anything but their intended purpose, but I don't want to make a similar mistake again and would like to know the rationale behind having language keywords that are not reserved in certain circumstances.

like image 870
PeterT Avatar asked Dec 02 '10 19:12

PeterT


People also ask

When is C-section done?

A C-section might be recommended for women with certain health issues, such as a heart or brain condition. There's a blockage. A large fibroid blocking the birth canal, a pelvic fracture or a baby who has a condition that can cause the head to be unusually large (severe hydrocephalus) might be reasons for a C-section.

How big does a baby have to be for cesarean?

Cesarean Section A C-section may be necessary if there are concerns for your safety or the safety of your baby. Your doctor will recommend it if the baby could be larger than 11 pounds (5000 grams) or you have diabetes and the baby's estimated weight is more than 9 pounds 15 ounces (4500 grams).

Does your cervix open during C-section?

During elective (planned) caesarean sections, some obstetricians routinely dilate the cervix intraoperatively, using sponge forceps, a finger, or other instruments, because the cervix of women not in labour may not be dilated, and this may cause obstruction of blood or lochia drainage.

Are C-sections painful?

You won't feel any pain during the C-section, although you may feel sensations like pulling and pressure. Most women are awake and simply numbed from the waist down using regional anesthesia (an epidural and/or a spinal block) during a C-section.


2 Answers

Some keywords are only reserved in certain contexts, e.g., the partial in partial class.

See the "contextual keywords" under this topic on MSDN.

like image 171
Stephen Cleary Avatar answered Oct 09 '22 07:10

Stephen Cleary


The C# team specifically tries to avoid creating new reserved keywords in the language. Any new keyword added means that it automatically breaks existing code which used that keyword as an identifier. Hence whenever possible C# will use a contextual keyword to minimize or eliminate the possibility of breaking existing code.

A contextual keyword is one that is only a keyword when used in a specific context like from, partial, var, etc ... That context does not include identifiers :)

I do not believe there's been a new keyword added since C# 2.0 (not even sure 2.0 added one)

like image 40
JaredPar Avatar answered Oct 09 '22 07:10

JaredPar