2016-04-11 15 views
-1

Önemsiz soru, ancak sonuçların konsol penceresine gönderilmesiyle ilgili olarak nasıl giderim. Bu veri türünü ana bilgisayara nasıl geçireceğini bilmiyorum.Konsol penceresine çıkış

namespace Node 
    { 
     class Program 
     { 
      public static int appLayer(int humData) 
      { 
       int tempData1 = 55; 
       int tempData2 = 60; 
       int tempData3 = 58; 
       int tempData4 = 58; 
       int [] tempData = new int[] {tempData1, tempData2, tempData3, tempData4}; 

       Dictionary<int, int> count = new Dictionary<int, int>(); 
       foreach (int a in tempData) 
       { 
        if (count.ContainsKey(a)) 
         count[a] = count[a] + 1; 
        else 
         count[a] = 1; 
       } 
       int result = int.MinValue; 
       int max = int.MaxValue; 
       foreach (int key in count.Keys) 
       { 
        if (count[key] > max) 
        { 
         max = count[key]; 
         result = key; 
        } 
       } 
       return result; 
      } 
      static void Main(string[] args) 
      { 
       Console.WriteLine("The mode is: " + result); 
      } 
     } 

size

cevap

1

Sen) şimdi anladım

 static void Main(string[] args) 
     { 
      var result = appLayer(0); // 0 is the parameter value for humData which is not used so you can remove it... 
      Console.WriteLine("The mode is: " + result); 
      Console.ReadLine(); // Add this to the end to have a pause on the console app 
     }   
+0

bir Console.Read() veya Console.ReadLine (ana iç yöntemini çağırmak ve eklemek zorunda. Hızlı ve açık bir açıklama için teşekkürler. – Tom

1
static void Main(string[] args) 
{  
    int result = appLayer(); 
    Console.WriteLine("The mode is: " + result); 
} 

VEYA

static void Main(string[] args) 
{  
    Console.WriteLine("The mode is: " + appLayer()); 
} 

ederiz humData parametredir çünkü appLayer prototipi

public static int appLayer() 

olmalıdır şöyledir: ben koduna sahip kullanılmamış.

İlgili konular