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. Simple yet unanswered question

Simple yet unanswered question

Scheduled Pinned Locked Moved C#
question
3 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.
  • H Offline
    H Offline
    hatim_ali
    wrote on last edited by
    #1

    Why constructors don't return values ??

    J G 2 Replies Last reply
    0
    • H hatim_ali

      Why constructors don't return values ??

      J Offline
      J Offline
      J Dunlap
      wrote on last edited by
      #2

      Because constructors are called when a new class is created, and therefore what is returned to the caller is a new instance of the class.

      "A people that values its privileges above its principles soon loses both."
      -- Dwight D. Eisenhower

      1 Reply Last reply
      0
      • H hatim_ali

        Why constructors don't return values ??

        G Offline
        G Offline
        Giles
        wrote on last edited by
        #3

        As an extra to the previous answer, if you want to inicate that something in the constructor did not work as expected, throw an exception, that or provide an extra initialisation function for use after the object was constructed.


        "Je pense, donc je mange." - Rene Descartes 1689 - Just before his mother put his tea on the table. Shameless Plug - Distributed Database Transactions in .NET using COM+

        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