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
-1
votes
1 answer

How do I apply CSS to part of the c:out value

I am trying to use c:out value=myClass.myMethod to output a value. in the java code of myMethod I am trying to add css class stlying to cause part of the outputted string to be modified by the a stringPart1 stringPart2 Therefore, I build the…
user2631746
  • 11
  • 1
  • 1
-2
votes
1 answer

keep getting 'list index out of range' while list is existing in python

I am trying to give the last element of at @2@ into , then use it to set the if condition. But it only brings me 'list out of index' message. Just in case, I tried to use a deep copy but it gives me the same result. I want to know how…
-2
votes
2 answers

Multiple return variables - which has best performance (out, tuple, class)?

A method that returns multiple doubles can be realized in various ways: Through out parameters: class MyClass { static double Add3(double x, out double xp1, out double xp2) { xp1 = x + 1.0; xp2 = x + 2.0; return x +…
Amos Egel
  • 937
  • 10
  • 24
-2
votes
2 answers

Capturing visible text from Power shell window for the command that is not internal to power shell

Tried using '>' and 'OUT' commands but it is writing different output to the file that is not appearing in power shell window. Please note that these commands are application specific.
-2
votes
3 answers

Unecessary assignment of a value c# when using out

I recently came up to the following Message with the code below string errorMessage = String.Empty; I've been getting: Message IDE0059 Unnecessary assignment of a value to 'errorMessage' The only place this is used was var valid = IsValid(out…
Athanasios Kataras
  • 25,191
  • 4
  • 32
  • 61
-2
votes
1 answer

How to retrieve the out parameter of an asynchronous method that runs on another thread

I created a class Out, intending to use it as an out parameter in async methods. class Out { public T Value { get; set; } } Here is an example of how I intend to use it: async Task DoWorkAsync(Out arg) { arg.Value = 13; await…
Theodor Zoulias
  • 34,835
  • 7
  • 69
  • 104
-2
votes
2 answers

Why passing string to a method behaves unlike List if they are both reference type?
I was reading a code that made me stop at some line: List props = new List(); DoWork(param1, param2, props); //props.Count grew up I was thinking that changing a variable outside its scope requires passing it as out or ref, but then…
mshwf
  • 7,009
  • 12
  • 59
  • 133
-2
votes
2 answers

What is "2" in command, while redirecting both System.out , System.err Java messages to file

I just figured that, we can redirect both System.out and System.err messages to a file, am not able to understand this command which does redirecting while running this below file using : java StandarProgram> output.log 2>error.log What is 2? and…
vinay
  • 63
  • 2
  • 10
-2
votes
1 answer

ArrayIndexOutOfBoundsException Pleas help me

i have a Problem with my Java Code. I tried everything to figure out whats the issue for the error. Maybe you can help me out. public static void Convert1() throws IOException,ArrayIndexOutOfBoundsException,NumberFormatException { String csv…
-2
votes
1 answer

terminate called after throwing an instance of 'std::out_of_range'

// Headers and namespace #include #include #include #include #include using namespace std; int main() { //Create original table vector table = { "ABCDE", "FGHIJ", "KLMNO", "PRSTU",…
Jon
  • 11
-2
votes
1 answer

Java Multidimensional Array Outprint

I dont understand, why these numbers are printed out. Shouldn't it just out print 3 2 1? Instead, it prints: 3 0 0 0 2 0 0 0 1 Thank you for your help :) public static void main(String[] args) { int i, j, n = 3; int[][] polje = new…
energetics
  • 25
  • 4
-2
votes
1 answer

passing out parameters in different level of functions

I have linklist c-program which is working correctly, but a late requirement was that no global variables must be use. So I had to redesigned everything to avoid passing out parameters, but there are parts which is hard to redesign and some of the…
fyeth fyeth
  • 93
  • 3
  • 10
-2
votes
1 answer

Out of memory error when using bitmap

I know this is a common question but I did not find an appropriate answer to my problem in other threads. I use bitmaps in my application for displaying profile pictures of users. In addition, the app is like Instagram, so there is a page that is…
Yoni4949
  • 15
  • 3
-2
votes
1 answer

Getting a "vector subscript out of range" error when passing a vector into a function: c++

I am trying to write a c++ program that assembles MIPS instructions. While debugging, it keeps throwing an error at line 74 of my main: myassembler.add(lexed[i].labels[0], lexed[i].name, tokens, i); my main is here: #include #include…
fuwafuwa
  • 11
  • 3
-2
votes
2 answers

C# - Can't pass Out with an Override method

I have a method very similar to the example below, and it won't let me out the outItem. public override bool myMethod(string item, out string outItem) { outItem = ""; return true; } It keeps giving the the following…
bluefox
  • 136
  • 2
  • 16