C#
 Computer >> コンピューター >  >> プログラミング >> C#

メソッドがC#でオーバーロードされるさまざまな方法は何ですか?


メソッドをオーバーロードできるさまざまな方法は-

です。
The datatypes of parameters are different
The number of parameters are different

以下に、パラメータのさまざまなデータ型を示す例を示します-

void print(int i) {
   Console.WriteLine("Printing int: {0}", i );
}

void print(double f) {
   Console.WriteLine("Printing float: {0}" , f);
}

void print(string s) {
   Console.WriteLine("Printing string: {0}", s);
}

以下に、パラメータの数の違いを示します-

// two parameters
public static int mulDisplay(int one, int two) {
   return one * two;
}

// three parameters
public static int mulDisplay(int one, int two, int three) {
   return one * two * three;
}

// four parameters
public static int mulDisplay(int one, int two, int three, int four) {
   return one * two * three * four;
}

  1. Cプログラミングの関数のさまざまなカテゴリは何ですか?

    引数が存在するかどうか、および値が返されるかどうかに応じて、関数は-に分類されます。 引数も戻り値もない関数 引数なしで戻り値のある関数 引数ありで戻り値のない関数 引数と戻り値を持つ関数 引数と戻り値のない関数 例 #include<stdio.h> main (){    void sum ();    clrscr ();    sum ();    getch (); } void sum (){    int a,b,c;   &

  2. C#を学習するための前提条件は何ですか?

    C#の学習を開始するには、まずコンピューターの知識が必要です。それで、CまたはC#での事前の学習経験があれば、それは素晴らしいことです。 C#から始めるには、最初にVisualStudioをインストールします。現在のバージョンはVisualStudio2017です。 かさばるVisualStudioIDEをインストールする手間を省きたい場合は、オンラインコンパイラから始めることができます。 C#プログラムを実行するためのトップオンラインコンパイラは- コーディンググラウンド DotNetFiddle 上記は両方ともインテリジェントコンパイラです。そこに行き、C#コードを