Author Topic: C#6 using static  (Read 1510 times)

0 Members and 1 Guest are viewing this topic.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
C#6 using static
« on: November 29, 2015, 07:20:11 PM »
Can anyone see an advantage gained by the using static directive in C#6.0

I'm wondering if it's use in production code will lead to confusion regarding the home for Methods.

Considering the time relationship between writing code and reading code it wouldn't take long for any saving in code generation to be whittled away.
« Last Edit: November 29, 2015, 07:25:01 PM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: C#6 using static
« Reply #1 on: November 30, 2015, 01:12:58 AM »
Hi,

I started using it with the Math class.
Speaking English as a French Frog

CADbloke

  • Bull Frog
  • Posts: 342
  • Crash Test Dummy
Re: C#6 using static
« Reply #2 on: November 30, 2015, 02:36:47 AM »
I haven't used it yet but I would avoid using it where it wasn't bleedingly obvious, as in Giles' example with the Math class. As you mentioned, you will have to read that code at a later date - the less between-the-words interpretation you need to do then, the easier it will be for you to human-parse and maintain. That's the same reason I use ridiculously verbose variable names, memory like a...ummm....