6

Unlike C++, C, etc there are very few undocumented behavior in C# as opposed to the .NET framework.

All programmers are aware about the dangers comparing floating point numbers…

When doing a code review it is often useful to have a checklist, one par to the checklist normally contains “undocumented behaviour” that shop be spotted and removed.

What undocumented behaviour should be on such a check list for C# and what version(s) of C# are there a program in.


This question was prompted by “How are ambiguous enum values resolved in C#?”, I was surprised by the answer as in my many years as a C# programmer I do not recall coming across any bugs in C# code due to the use of undefined behaviours apart from float point numbers.

I recall from my distant past when I write C++ code, that coding standards etc often had lists of undefined behaviours to be avoided, but have never seen such a list for C#.

Community
  • 1
  • 1
Ian Ringrose
  • 51,220
  • 55
  • 213
  • 317
  • 4
    Dont you `undefined` behavior? – leppie Jul 21 '14 at 08:28
  • you haven't even specified the .NET/C# version – AndersK Jul 21 '14 at 08:29
  • I am not getting the question, can any one explain in comment by giving example or something :) – Jageen Jul 21 '14 at 08:30
  • @Jageen, I have added more details to the quesion – Ian Ringrose Jul 21 '14 at 08:37
  • 1
    I would have to disagree with "All programmers are aware about the dangers comparing floating point numbers" unless there are some `` tags missing from your question. Given people keep asking questions about why floats in (pick a language/enivornment) are buggy... – Damien_The_Unbeliever Jul 21 '14 at 08:50
  • 4
    Bit of a stretch to say that this is "primarily opinion based"? If a particular behaviour is not defined in the C# Spec, that is not based on opinion, it is fact. I think this would have produced some useful discussion. – dtsg Jul 21 '14 at 08:50
  • @dtsg I don't know, there seems to be a difference of opinion as to whether the enum behaviour linked is documented or not. – Rawling Jul 21 '14 at 08:52
  • 1
    C++ documents a lot of behavior as 'undefined'. – H H Jul 21 '14 at 09:03
  • @Damien_The_Unbeliever, I would not call these people "programmers"! – Ian Ringrose Jul 21 '14 at 10:48

0 Answers0