Default Type [modified]
-
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
-
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
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 )
-
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 )
Thanks, but still i feel you missed to reply my queries...default type
-
Thanks, but still i feel you missed to reply my queries...default type
Well - all classes ultimately inherit from
object
.Deja View - the feeling that you've seen this post before.
-
Well - all classes ultimately inherit from
object
.Deja View - the feeling that you've seen this post before.
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
-
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
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
-
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
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.
-
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
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.