Questions tagged [out]

In c#, the out keyword causes parameters to be passed by reference from the callee to the caller. The parameter doesn't have to be assigned going into a function but must be assigned before coming out of the function.

The out keyword causes arguments to be passed by reference. This is similar to the ref keyword, except that ref requires that the variable be initialized before being passed. To use an out parameter, both the method definition and the calling method must explicitly use the out keyword. For example:

class OutExample
{
    static void Method(out int i)
    {
        i = 44;
    }
    static void Main()
    {
        int value = 2;
        Method(out value);
        // value is now 44
    }
}

Although variables passed as out arguments need not be initialized prior to being passed, the called method is required to assign a value before the method returns.

The ref and out keywords are treated differently at run-time, but they are treated the same at compile time. Therefore methods cannot be overloaded if one method takes a ref argument and the other takes an out argument.

598 questions
0
votes
0 answers

Use of unassigned out variable though i assign it a default value

using System; namespace Examples { public class HelloWorld { public static void Main(string[] args) { int y=5; A(out y); } public static void A(out int x) { Console.WriteLine(x); x=1; …
Dilip Nandakumar
  • 198
  • 2
  • 14
0
votes
2 answers

Windows Server 2012 System.IndexOutOfRangeException

I have wrote a service and it works just fine on my computer but when I move it onto the server it is supposed to run on, it is spitting out System.IndexOutOfRangeException whenever it goes to read/write the file like its supposed too. I just find…
user345453
  • 52
  • 1
  • 10
0
votes
3 answers

Java Arry Index Out of Bound Exception

I have been working on this basic java program when I need to store 5 user entered values into an array, send it to a method, and find and display the lowest value. The program is simple enough, and it runs, but when I enter the last number, I get…
tserran
  • 53
  • 1
  • 4
  • 13
0
votes
2 answers

How to circumvent unused out parameters values?

I am using ConcurrentDictionary, and I need to remove elements using TryRemove. The implementation of TryRemove requires an out parameter that returns the object that will be removed. Body dummy; if (!bulletBodies.TryRemove(bullet, out…
Larry
  • 17,605
  • 9
  • 77
  • 106
0
votes
3 answers

Program efficiency and java.lang.OutOfMemoryError: Java heap space

The problem is to remove every 2nd element until the last one remains. (Assuming the elements are placed in circle) My program works fine for small values of n but when i use a large value it gives me a java.lang.OutOfMemoryError: Java heap space…
ik024
  • 156
  • 3
  • 14
0
votes
2 answers

Java heap space with LinkedLists and Nodes

For computer Science I'm coding a program that keeps the "tails" end of head, a Node so that I can add and remove from the Node/LinkedList. This isn't entirely difficult, but I've run into an issue that makes me cry. I am running into java heap…
0
votes
1 answer

ZF2 retrieve out parameter from SP call

I have created a stored procedure with following declaration: DELIMITER $$ DROP PROCEDURE IF EXISTS my_test$$ CREATE PROCEDURE my_test(input_number INT, OUT out_number text) BEGIN IF (input_number = 0) THEN SET…
0
votes
1 answer

Where can I find out.xml file for an Android Application?

Since I am new to Android I got stuck in a problem that seems to be pretty common for newbies (Error in an XML file: aborting build), after trying to add a new string in my strings.xml file. I have searched the web and many developers (actually,…
SunnyDay
  • 317
  • 2
  • 8
  • 19
0
votes
1 answer

Dynamically invoking RavenDB Statistics method regardless of query source

RavenDB provides 2 APIs for querying data, IDocumentQuery for advanced lucene query and IRavenQueryable for a strongly typed linq provider model. They share a method called Statistics(out RavenQueryStatistics stats) that returns information at…
Chris Marisic
  • 32,487
  • 24
  • 164
  • 258
0
votes
5 answers

scanner.nextInt(), out of range avoidance?

I've finished a simple program that converts a decimal number to binary (32bit). I would like to implement some type of error message should the user enter in an overflow number (anything over 2147483647). I tried a if_else , loop, but quickly found…
0
votes
1 answer

Need to out 4 variables from c++ to java using jni

I'm good in c# and i need help in JAVA. I have a c++ function that outs 4 variables int Func1(int inParam1, unsigned char* inParam2, int *outParam1, int *outParam2, int *outParam3, unsigned char** outParam4); I can call this function from C# using…
Narayan
  • 1,189
  • 6
  • 15
  • 33
0
votes
2 answers

Working with WinAPI functions which use C style strings as OUT parameters

Given a WinAPI function which returns it's result via a C style string OUT parameter e.g.: int WINAPI GetWindowTextW( _In_ HWND hWnd, _Out_ LPTSTR lpString, _In_ int nMaxCount ); Is there a better way of using the function than what…
JBentley
  • 6,099
  • 5
  • 37
  • 72
0
votes
3 answers

Java reflection to change parameter?

I'm writing a method in Java that I want to simulate references.. Since java doesn't have the out keyword like in C# and doesn't have References/Pointers like in C++, I want to know if I can use reflection to simulate it. An example would be: public…
Brandon
  • 22,723
  • 11
  • 93
  • 186
0
votes
1 answer

Capturing audio out for use in a web page

I am wondering if it is possible, using JavaScript, php, or any other method to capture general 'audio out' or line out, and send it to be used in a web page.
TGYK
  • 13
  • 6
0
votes
3 answers

Java IndexOutOfBoundsException

I created a little android game but I am getting weird error. Here is log: 12-31 16:10:22.407: E/AndroidRuntime(12824): FATAL EXCEPTION: Thread-1461 12-31 16:10:22.407: E/AndroidRuntime(12824): java.lang.IndexOutOfBoundsException: Invalid…
carobnodrvo
  • 1,021
  • 1
  • 9
  • 32