Questions tagged [ref]

The ref keyword causes an argument to be passed by reference, not by value. The effect of passing by reference is that any change to the parameter in the method is reflected in the underlying argument variable in the calling method. The value of a reference parameter is always the same as the value of the underlying argument variable.

1394 questions
0
votes
1 answer

f# custom linked list and references

i am new to this language. In order to try and understand referencing i have tried implementing a simple directed list the freshman college computer science way. type item = { value:float next:ref } type list() = let…
0
votes
0 answers

C# When should I ever use "out" over "ref?"

I completely understand the use of out and ref in C# however why would I ever use out instead of ref as out is simply the same as ref just with restricted abilities. I see when it can be used but I don't see any point in ever using it really. Thanks…
jer_francis
  • 153
  • 1
  • 11
0
votes
2 answers

Perl hash giving strict refs error

I am trying to write code to add up revenue on sales based on the month of a particular year and output total per month per year, something with my code is wrong though and I am just stuck now. use strict; use warnings; my @newPlans = `cat…
ThatGuy
  • 303
  • 2
  • 14
0
votes
1 answer

Sending property as a reference param to a function in iOS?

I want to do something like this: @property (nonatomic, retain) NSObject *obj1; @property (nonatomic, retain) NSObject *obj2; - (id)init { if ((self = [super init])) { [SomeClass someFuncWithParam1:*(self.obj1) param2:*(self.obj2)]; …
user2159978
  • 2,629
  • 2
  • 16
  • 14
0
votes
1 answer

ref class , returning a vector of labels

I am trying to return a number of created labels in a vector to a form and then add them to the form. But i get a lot of errors, my guess is that i'm using the ref class (that i use the pointer ^) wrong. The code (a little modified) work at first in…
0
votes
4 answers

c# error returning value from function

I am tring to use a method or function to create the directory tree that I need, and return the new path to the calling procedure. But I cannot get it to compile I get an error cannot convert method group 'localAttachmentsPath' to non delegate type…
Our Man in Bananas
  • 5,809
  • 21
  • 91
  • 148
0
votes
2 answers

String.Format parameters OUT c#

I have a system for a store, and they ask me for to put the function of Log4Net, the configuration is all ready, my code is String cParameters1 = String.Format("PROJECT:WebERP, CLASS: OrdersMain.aspx.cs, " + "METHOD:…
0
votes
1 answer

Interlocked functions in Haxe

I am new to Haxe. When I try to convert the following line from C# to Haxe using CS2HX: Interlocked.Increment(ref this.fieldName); I get error from CS2HX: ref/out cannot reference fields, only local variables Now this makes me wonder - are…
Roland Pihlakas
  • 4,246
  • 2
  • 43
  • 64
0
votes
1 answer

How to use the ref attribute without allowing multiple roots

I'm trying to validate a simple XML using XSD, however i'm facing a problem concerning the ref attribute. I use this XSD to validate the XML :
GdC
  • 189
  • 1
  • 1
  • 9
0
votes
0 answers

Generic method with a custom generic action delegate parameter which itself has a ref parameter

[EDIT] I Do apologize, this construct is working as it should. here is my delegate type and my generic method: public class SomeClass { public delegate void RefAction(ref TRef refArg, T arg); public static void MyMethod
jambodev
  • 351
  • 2
  • 3
  • 9
0
votes
0 answers

passing by ref object to VB dll not working

first post from newbie after having spend three days googling and reading MSDN: From C# I'm trying to call a method in a VB dll which starts like this: Public Function Correl(action As String, ByRef returns As Object, observation_frequency As…
AlexH
  • 21
  • 4
0
votes
1 answer

Optimizations with value types and method calls using ref

I'm making a simple particle system in C#/XNA, and since there would potentially be a high volume of method calls every second, I wanted to make sure I understood exactly how everything works. I have a Particle and Emitter class such that: public…
Kyle Baran
  • 1,793
  • 2
  • 15
  • 30
0
votes
2 answers

Cannot implicitly convert type void to double using using a type void method with ref parameters

I'm new to C# and am having big trouble with a reference parameter (static void type) that will not return a value to my Main() method. My compiler give the this error message: cannot implicitly convert type void to double. I have researched this…
user3080178
0
votes
4 answers

Using ref in C#

I am trying to write a basic program, with two classes. I can manage fine with one class: public static void Main (string[] args) { double radius; double height; double volume; { …
user3079327
0
votes
1 answer

Perl socket not functioning inside function

I'm trying to do a multithread client for a chat application. The are 2 threads: keyboard reading (reads input from the keyboard and sends it through a socket) and server reading (reads lines from the server and prints them to the screen). So, this…
user2938976
  • 235
  • 1
  • 3
  • 11