Need a method to return both a bool and an int

Can anyone show me an example of a method in C# that returns both a Bool and an INT . I think I need to write a method that returns some sort of <List> object but I'm not sure. Any help or direction provided would be most appreciated.
Who is Participating?
Mike TomlinsonMiddle School Assistant TeacherCommented:
You can return a Class or a Struct which would hold both your values.  Another option would be to pass a variable as "ref" allowing you to change its value within the method and have the original variable also change.
Here's simple class to use:

function Stuff as BOOLINT
         return new BOOLINT(1,99)
end function

Public Class BOOLINT
DIM _TFValue AS boolean
DIM _NumValue AS integer

Public Property TFValue () AS boolean
Return _TFValue
End Get
Set(ByVal value as boolean)
_TFValue = value
End Set
End Property

Public Property NumValue () AS integer
Return _NumValue
End Get
Set(ByVal value as integer)
_NumValue = value
End Set
End Property

Sub New(ByVal TFValue AS boolean, ByVal NumValue AS integer)
_TFValue = TFValue
_NumValue = NumValue

End Sub
End Class
you can have a function that takes an argument that is identified by 'out' keyword.


private bool MyBoolIntFunction(out int someNumber) {
   someNumber = 5;
   return true;
Naman GoelSoftware engineer 1Commented:
you can do any thing like above said

private bool Method(out int number)
    bool value=false;
    return value;

or create a structure or class with values

public class BoolInt
public int Integer{get;set;}
public bool Boolean {get;set'}

private BoolInt Method()
    BoolInt boolInt= new BoolInt();
    boolInt.Boolean =false;
    return boolInt;

or something like this:

private KeyValuePair<int, bool>Method()
        return new KeyValuePait<int, bool>(10,false);

jazzcatoneAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.