Use out : out « Language Basics « C# / CSharp Tutorial






using System; 
 
class Decompose { 
 
  public int parts(double n, out double frac) { 
    int whole; 
 
    whole = (int) n; 
    frac = n - whole; // pass fractional part back through frac 
    return whole; // return integer portion 
  } 
} 
  
class MainClass { 
  public static void Main() {   
   Decompose ob = new Decompose(); 
    int i; 
    double f; 
 
    i = ob.parts(10.125, out f); 
 
    Console.WriteLine("Integer portion is " + i); 
    Console.WriteLine("Fractional part is " + f); 
  } 
}
Integer portion is 10
Fractional part is 0.125








1.12.out
1.12.1.Use 'out' keyword (no need to assign because it is an out)
1.12.2.Ref and Out Parameters
1.12.3.Out Parameters
1.12.4.Use out
1.12.5.Use two out parameters