Advertisement
Guest User

Example

a guest
Apr 24th, 2017
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Example1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             //Populates the 'values' list
  14.             for (int i = 0; i < 10; i++)
  15.                 values.Add(i);
  16.  
  17.             Console.WriteLine(getSum);
  18.  
  19.         }
  20.  
  21.         static List<double> values = new List<double>();
  22.  
  23.         static double getSum
  24.         {
  25.             get
  26.             {
  27.                 double sum = 0;
  28.  
  29.                 foreach(double d in values)
  30.                 {
  31.                     sum += d;
  32.                 }
  33.  
  34.                 return sum;
  35.             }
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement