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
  1. Home
  2. General Programming
  3. C#
  4. Static function

Static function

Scheduled Pinned Locked Moved C#
question
4 Posts 3 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.
  • D Offline
    D Offline
    dinh van hai
    wrote on last edited by
    #1

    hi everybody, I would like to ask a question here. Is Static function advantage or disadvantage ? How are they disadvantage ? Shuold I use many static function in a program ? Thank for answering my questions , Sincerely,

    S D G 3 Replies Last reply
    0
    • D dinh van hai

      hi everybody, I would like to ask a question here. Is Static function advantage or disadvantage ? How are they disadvantage ? Shuold I use many static function in a program ? Thank for answering my questions , Sincerely,

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      dinh van hai wrote:

      Is Static function advantage or disadvantage ?

      Depends on the context. Static functions are useful for factory methods like Create, which create and return appropriate objects.

      dinh van hai wrote:

      How are they disadvantage ?

      Static functions are like global functions, only that their scope is restricted to the class. So too many static functions and the class then becomes a dumping ground where you keep adding functions that don't fit elsewhere.

      dinh van hai wrote:

      Shuold I use many static function in a program ?

      Of course you can. You can take the system defined static functions, like File.Create as a starting point. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

      1 Reply Last reply
      0
      • D dinh van hai

        hi everybody, I would like to ask a question here. Is Static function advantage or disadvantage ? How are they disadvantage ? Shuold I use many static function in a program ? Thank for answering my questions , Sincerely,

        D Offline
        D Offline
        dinh van hai
        wrote on last edited by
        #3

        how do static functions affect the performence and memory of our program ?

        1 Reply Last reply
        0
        • D dinh van hai

          hi everybody, I would like to ask a question here. Is Static function advantage or disadvantage ? How are they disadvantage ? Shuold I use many static function in a program ? Thank for answering my questions , Sincerely,

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          If the function doesn't use any data from the instance of the class, it should be static, so that you don't have to create an object just to call the function. Declaring a function as static also supplies the information that the function is self-contained and doesn't need any data from an object. --- b { font-weight: normal; }

          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