byval

Best Practice: ByRef or ByVal? in .Net

What are the things to consider when choosing between ByRef and ByVal. I understand the difference between the two but I don't fully understand if ByRef saves resources or if we even need to worry about that in the .Net environment. How do you decide between the two if the functionality doesn't matter in a situation? ...

Which is faster? ByVal or ByRef?

In VB.NET, which is faster to use for method arguments, ByVal or ByRef? Also, which consumes more resources at runtime? (RAM) Edit: I read through this question, but the answers are not applicable or specific enough. ...

Pass anonymous function by value in javascript?

I have a function that accepts an anonymous function as an argument and sets it to a variable (scoped) for reference. I then try to execute another function with that reference but it obviously fails since that function is out of scope. I was wondering if anyone knew of a simple way of passing the anonymous function straight through as...

VB.NET: If I pass a String ByVal into a function but do not change the string, do I have one or two strings in memory?

I know strings are immutable, so the minute you change a string reference's value .NET makes a brand new string on the heap. But what if you don't change the value of a string reference; rather, you simply pass it into a function ByVal -- does this operation copy the string value on the heap as well? My inclination is "no," but I'd l...

How to make absolute cell ref in loop work and skipping over a column in loop?

I ALMOST got my code working but there are still two things wrong with it (two major things anyway). 1) The absolute cell ref. is not working as it does in Excel. I want for example $A5 but instead of changing to A6 A7 etc., it stays A5 throughout the loop. 2) There is a third column that I need to skip over. I only need my loop to wri...

Update properties of objects in an IEnumerable<>

Hi, I am working on some software that should be used for a special type of experiment. The experiments are performed using: 1) A "Chip" (basically an XY grid of known dimensions). 2) Each Chip contains "Electrodes", identified by their X and Y coordinate on the chip and by a unique ID. Each electrode can also hold or not hold a sampl...

Instantiate Local Variable By Value?

I sort of understand why this is happening, but not entirely. I have a base class with a Shared (Static) variable, declared like so: Public Shared myVar As New MyObject(arg1, arg2) In a method of a derived class, I set a local variable like so: Dim myLocalVar As MyObject = myVar Now when I do something like myLocalVar.Property1 += ...

Switching Byref to Byval on method calls VB.NET

Switching Byref to Byval on method calls I have many warnings raised due to: "Implicit conversion from xxxx to yyyy in copying the value of 'ByRef' parameter zzzz back to the matching argument." My feeling is that it would be safe to change the function parameters from byref to byval as nothing special is being done with the reference...

How to 'do' ByVal in C#

As I understand it, C# passes parameters into methods by reference. In vb.net, you can specify this with ByVal and ByRef. The default is ByVal. Is this for compatibility with vb6, or is it just random? Also, how can I specify what to use in C#? I kind of like the idea of passing parameters by value. ...

[VB.Net] ByRef vs ByVal performance when passing strings

Hello everyone! Reading http://stackoverflow.com/questions/408101/which-is-faster-byval-or-byref made me wonder whether the comments in there did apply to Strings in terms of performance. Since strings are copied before being passed, isn't it much more efficient (if the callee doesn't need a copy of string course) to pass strings ByRef?...