2016-09-23 9 views
-3

に密閉されたクラスで定義された静的関数を呼び出すために、私は公共のクラスを持っており、下記のように、それは静的な機能が含まれています: -どのようにC#の

public class demo1 
{ 
    public static int GetFactorials(int number) 
    { 
     int result = 1; 

     for (int i = 1; i <= number; i++) 
     { 
      result *= i; 
     } 
     HttpContext.Current.Response.Write(result); 
     return result; 
    } 
} 

この静的関数GetFactorialsを呼び出す方法?

+1

は '' demo1.GetFactorials(1)を試してみてください –

答えて

2

スタティック関数/メソッドはオブジェクトを必要としません。

demo1.GetFactorials(10); 
2

それは簡単です:

demo1.GetFactorials(123);