Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. "using" keyword on methods

"using" keyword on methods

Scheduled Pinned Locked Moved C#
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    udir
    wrote on last edited by
    #1

    Hi All, I have to write a mathematics formula with lots of sin and cos fuctions. It is very inconvenient since I have to write system.math.sin/cos. I know I can use the using keyword as followed : using system.math to shortcut a little bit my method to math.sin/cos but it still annoying. I know I can't but why can't I write the following using sin = system.math.sin; using cos = system.math.cos; ??? Does anyone has an idea for a clean solution ?? thanks in advanced, Udi Raz

    L 1 Reply Last reply
    0
    • U udir

      Hi All, I have to write a mathematics formula with lots of sin and cos fuctions. It is very inconvenient since I have to write system.math.sin/cos. I know I can use the using keyword as followed : using system.math to shortcut a little bit my method to math.sin/cos but it still annoying. I know I can't but why can't I write the following using sin = system.math.sin; using cos = system.math.cos; ??? Does anyone has an idea for a clean solution ?? thanks in advanced, Udi Raz

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      You can only alias types, not members. I agree it would be nice, but I dont think the compiler could handle that. Anyways, in your class:

      double cos(double a) { return Math.Cos(a); }
      double sin(double a) { return Math.Sin(a); }

      xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups