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
2 answers

Is there a better way to hold a variable reference from a factory in individual class interfaces?

In this first attempt I'm trying to keep a reference of a variable in DialogBoxFactory by injecting either an int or string to an IDialogFooterText, and call 'GetFooterDisplay()' in my factory which then returns a string. I was simulating a dialog…
user2183858
  • 25
  • 1
  • 3
0
votes
4 answers

Deleting a reference to a locally-created pointer

Consider I have the function: int &create_ptr(){ int *x = new int; *x =5; return *x; } int main(){ int y = create_ptr(); } Will this cause a memory leak or is there somehow to delete it? Sorry if it's a basic question, this has just…
0
votes
1 answer

Struggle with ref string input type - read only - need to write

What I want to do: create a function that takes a string and a single char as input. The function then shall "flip" every char according to the input char to a lower or upper case char. My Problem: I want to do this with a ref string input,…
wftico
  • 73
  • 1
  • 9
0
votes
8 answers

Property by ref C# (many parameters)

chaps/chapettes, I understand there are questions related to this but this is somewhat different - all related questions I could find only used one parameter as an example. Anyways, to the point: This year, I have converted source code written in…
dw1991
  • 51
  • 1
  • 5
0
votes
2 answers

Finding all controls in aspx page by reference

I need to change the visibility of many controls in my aspx page. I found several methods to get the controls like this one But I can't set values to this controls because they are passed by val, and I don't figure out how can I add the ref key word…
ihebiheb
  • 3,673
  • 3
  • 46
  • 55
0
votes
2 answers

Using ref to pass delegate

Delegate are reference type but still when trying to pass it to a method it requires a ref keyword. This reminds me of string that requires ref to be modified within a method because they are immutable, are delegate immutable? Here is my mini…
Everts
  • 10,408
  • 2
  • 34
  • 45
0
votes
2 answers

Porting C++ Code to C# - Pointer Issue

I'm trying to convert C++ code into C#. We have functions that accept pointers in C++. In C# we are having troubles doing it. We have tried the following demo code: namespace ConsoleApplication1 { class Program { static void…
Ashish Charan
  • 2,347
  • 4
  • 21
  • 33
0
votes
2 answers

Out argument of function call should maintain initialized value

I have defined a function where one of the parameters is out. Here, when the function call is made, I pass either a an initialized or an uninitialized argument. Now, in the case of an initialized argument, how do I make the callee not change the…
Tyler Durden
  • 1,188
  • 2
  • 19
  • 35
0
votes
0 answers

Passing structs as intptrs or ref to unmanaged code

I've been trying to pass information to/from c# into a c++ dll. I'm not able to alter the dll at all. Basically, i've found a method that works - but i don't quite understand why this method works, when others don't. If i can get some sort of…
user2477533
  • 201
  • 1
  • 2
  • 10
0
votes
1 answer

convert multilevel hash ref into HTML table with parent child relationship in perl

I have a multiple level hash ref having parent and child relationship and I want to convert that hash into simple HTML table with all relationships. my hash looks a like: $VAR1 = { '4' => { 'forumid' => '136720', …
manu
  • 47
  • 1
  • 4
0
votes
1 answer

Facebook Mobile page tab error: This page is for an app that doesn't work on mobile devices (tried ref=ts)

Previously I was able to get to my app on my Page Tab on mobile devices by appending ?ref=ts to the end of the app url on the page tab. Suddenly this has stopped working and i am now getting the following error message when trying on the…
0
votes
2 answers

How to pass a struct as a ref in a using clause?

Here's what I want to do: using(var bmp = Surface.FromBmp("smile.bmp")) { tex = Texture.FromSurface(ref rend, ref bmp); } Surface is a struct. I want to avoid making a copy of the struct just to pass it to Texture.FromSurface, so I'm passing it…
mpen
  • 272,448
  • 266
  • 850
  • 1,236
0
votes
1 answer

Add ref to list

I've read places that Controls cannot be loaded into an array or list and accessed in this manner, but I'm intrigued. My problem is as follows: I am displaying a week's worth of forecast data within my application. The forecast data is retrieved…
Nathan Brown
  • 311
  • 1
  • 3
  • 12
0
votes
0 answers

Mongoose schema change (with _id change)

I have a schema named card to update from {_id: ObjectId, id: String, ....} to {_id: String(same as id), id: String, ....} and update also a schema named users which is like {name: String, email: string, cards: {type: ObjectId, ref: 'card'}} how…
xDelph
  • 73
  • 7
0
votes
1 answer

Oracle: how to get an object reference?

I have a sales object and a table (tab1) of sales objects. I want to create a second table (tab2) that contains references to the objects in tab1. CREATE TYPE sales AS OBJECT ( marca NUMBER(4), nume VARCHAR2(40), orasp…
scarleth ohara
  • 357
  • 2
  • 12