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. Default Type [modified]

Default Type [modified]

Scheduled Pinned Locked Moved C#
questioncsharp
8 Posts 5 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.
  • A Offline
    A Offline
    Amit Kumar G
    wrote on last edited by
    #1

    A quick question: What is default type (ByVal/ByRef) in C# and Vb.Net? And which is a good practice if passing values to different components when they are on same machine and as well as on different machines.....Thanks!! Thanks. -- modified at 10:42 Monday 3rd September, 2007

    C 1 Reply Last reply
    0
    • A Amit Kumar G

      A quick question: What is default type (ByVal/ByRef) in C# and Vb.Net? And which is a good practice if passing values to different components when they are on same machine and as well as on different machines.....Thanks!! Thanks. -- modified at 10:42 Monday 3rd September, 2007

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Reference types ( classes ) are by reference, intrinsic types like int are by value. It really doesn't matter, anything that's not a trivial size is byref no matter what you do. In C# you can use ref or out to force by reference, but you cannot force by value.

      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      A 1 Reply Last reply
      0
      • C Christian Graus

        Reference types ( classes ) are by reference, intrinsic types like int are by value. It really doesn't matter, anything that's not a trivial size is byref no matter what you do. In C# you can use ref or out to force by reference, but you cannot force by value.

        Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        A Offline
        A Offline
        Amit Kumar G
        wrote on last edited by
        #3

        Thanks, but still i feel you missed to reply my queries...default type

        P 1 Reply Last reply
        0
        • A Amit Kumar G

          Thanks, but still i feel you missed to reply my queries...default type

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          Well - all classes ultimately inherit from object.

          Deja View - the feeling that you've seen this post before.

          A 1 Reply Last reply
          0
          • P Pete OHanlon

            Well - all classes ultimately inherit from object.

            Deja View - the feeling that you've seen this post before.

            A Offline
            A Offline
            Amit Kumar G
            wrote on last edited by
            #5

            Hey Chris/Pete I think we all are missing my queries a) What is default type (ByVal/ByRef) in C# and Vb.Net? b) Which is a good practice if passing values to different components when they are on same machine and as well as on different machines..... Thanks Thanks

            L O P 3 Replies Last reply
            0
            • A Amit Kumar G

              Hey Chris/Pete I think we all are missing my queries a) What is default type (ByVal/ByRef) in C# and Vb.Net? b) Which is a good practice if passing values to different components when they are on same machine and as well as on different machines..... Thanks Thanks

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              a) ByVal/ByRef are not types, they are keywords in VB.NET (and ref is in C#) b) best practice is to use what you need; i.e. use ByRef if the callee must be able to change the value/object as seen by caller, use ByVal otherwise. :)

              Luc Pattyn [Forum Guidelines] [My Articles]


              this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


              1 Reply Last reply
              0
              • A Amit Kumar G

                Hey Chris/Pete I think we all are missing my queries a) What is default type (ByVal/ByRef) in C# and Vb.Net? b) Which is a good practice if passing values to different components when they are on same machine and as well as on different machines..... Thanks Thanks

                O Offline
                O Offline
                originSH
                wrote on last edited by
                #7

                I think you might need to go back to basics and read up on the fundimentals of .Net. You can have two different types of type, one is reference types, the other is value types. By default reference types are passed by reference and value types are passed by value. Classes are reference types and structs/primatives are value types. If you don't understand any of this buy any beginner .Net book and it'll be in the first few chapters ;) As for best practice ... use what is needed.

                1 Reply Last reply
                0
                • A Amit Kumar G

                  Hey Chris/Pete I think we all are missing my queries a) What is default type (ByVal/ByRef) in C# and Vb.Net? b) Which is a good practice if passing values to different components when they are on same machine and as well as on different machines..... Thanks Thanks

                  P Offline
                  P Offline
                  Pete OHanlon
                  wrote on last edited by
                  #8

                  Ahh - I think I see what you are getting at. .NET differs from VB (6) in that it passes parameters by value and not by reference.

                  Deja View - the feeling that you've seen this post before.

                  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