Questions tagged [byref]

182 questions
7
votes
1 answer

Why can't a function with byref be converted directly to delegate?

Under normal circumstances, F# functions can be converted to delegates by calling new DelegateType and passing in the function as an argument. But when the delegate contains byref parameter, this is not possible directly. For example the code: type…
svick
  • 236,525
  • 50
  • 385
  • 514
7
votes
2 answers

Return object from PowerShell using a parameter ("By Reference" parameter)?

I have one PowerShell (2.0) script calling another. I want to receive back not only the main output, but an additional object that I can use separately, e.g. to display a Summary Line in a message. Let's have Test2.ps1 as the script being…
Mark Berry
  • 17,843
  • 4
  • 58
  • 88
7
votes
2 answers

How can I implement the same behavior as Dictionary.TryGetValue

So, given then following code type MyClass () = let items = Dictionary() do items.Add ("one",1) items.Add ("two",2) items.Add ("three",3) member this.TryGetValue (key,value) = items.TrygetValue (key,value) let c =…
pblasucci
  • 1,738
  • 12
  • 16
7
votes
6 answers

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…
Rob Sobers
  • 20,737
  • 24
  • 82
  • 111
6
votes
3 answers

What is the use of the := syntax?

I'm a C# developer working on a VB.NET project, and VS keeps trying to get me to use the := thingie when I call a function with a ByRef parameter like so: While reader.Read() HydrateBookFromReader(reader:=???) the HydrateBookFromReader function has…
Josh E
  • 7,390
  • 2
  • 32
  • 44
6
votes
2 answers

Property vs. Variable as ByRef parameter

I created a base class that implements the INotifyPropertyChanged interface. This class also contains a generic function SetProperty to set the value of any property and raise the PropertyChanged event, if necessary. Public Class BaseClass …
Nostromo
  • 1,177
  • 10
  • 28
6
votes
3 answers

Are 'by ref' arguments in WCF bad or good?

I've recently seen a WCF service declaring operation contracts with by ref arguments. I don't know why this design decision was taken (operations are void), but furthermore, I'm not able - from my WCF knowledge - to say if this is a good practice…
MatteoSp
  • 2,940
  • 5
  • 28
  • 36
6
votes
2 answers

By Ref parameters in VB.NET and C#

I have question related passing parameters byRef, I have VB.NET based class library in which some functions are defined with byref argument types. These parameters are parent class objects and when I tried to call this function and pass child class…
user2439901
  • 61
  • 1
  • 6
5
votes
4 answers

Pass PHP Class as Parameter

How can i pass a class as a parameter in my function So far i've tried $sc = new SampleClass(); SampleFunction($sc); function SampleFunction(&$refClass) { echo $refClass->getValue(); } this is a simplified example of what im doing.. i…
Philip Badilla
  • 1,038
  • 1
  • 10
  • 21
5
votes
0 answers

passing byref parameters to VB6 COM DLL from Python

I have a VB6 COM DLL with a function declared as follows: Public Function testFunc(ByRef v1 As Long) As Boolean When I try to call this from Python2.7 using: var1 = c_long() VB6DLL.testFunc(X1) If X1 is var1, then I get the exception: "int()…
tosa
  • 411
  • 1
  • 3
  • 23
5
votes
2 answers

Is there any way to deal with ParamArray values as byRef so they can be updated?

Sounds simple enough, but its not working. In this example, I want to set the values of 3 fields to equal a 4th. I could do something like this.... Dim str1 As String = "1" Dim str2 As String = "2" Dim str3 As String = "3" Dim str4 As String =…
StingyJack
  • 19,041
  • 10
  • 63
  • 122
5
votes
6 answers

Can you have "ByRef" arguments in AS3 functions?

Any idea how to return multiple variables from a function in ActionScript 3? Anything like VB.NET where you can have the input argument's variable modified (ByRef arguments)? Sub do (ByRef inout As Integer) inout *= 5; End Sub Dim num As Integer…
Robin Rodricks
  • 110,798
  • 141
  • 398
  • 607
5
votes
1 answer

F# method with byref parameter override

I'm trying to override a method with a byref parameter, the code below is an example type Incrementor(z) = abstract member Increment : int byref * int byref -> unit default this.Increment(i : int byref,j : int byref) = i <- i +…
Caelan
  • 940
  • 1
  • 7
  • 28
5
votes
1 answer

Why does ByRef not work in conjunction with WithEvents?

I think I have a fairly good idea what the difference is between ByVal and ByRef in VB, but my issue is when I try using it in conjunction with a member that is declared with WithEvents. I have the following method: Private Sub…
Francois Nel
  • 1,662
  • 2
  • 19
  • 29
4
votes
2 answers

'ByRef' parameter '' cannot be used in a lambda expression

I'm using SharpZipLib to compress files. The library is wrapped in a plugin interface, in a separate DLL. I pass the plugin dll a ByRef parameter to keep track of the compression progress. SharpZipLib, while compressing, will periodically call a…
Clément
  • 12,299
  • 15
  • 75
  • 115
1
2
3
12 13