Use out : Parameters Passing : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » Parameters Passing »

 

Use out









    

/*
C#: The Complete Reference 
by Herbert Schildt 

Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/
// Use out. 
 
using System; 
 
class Decompose { 
 
  /* Decompose a floating-point value into its 
      integer and fractional parts. */ 
  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 
  } 
} 
  
public class UseOut { 
  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); 
  } 
}


           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» Parameters Passing