一部の組み込みメソッドが機能しません。新しいメソッドを持たないアプリケーションに古いバージョンの .NetFramework を使用しています。そのため、組み込みメソッドをオーバーライドする拡張メソッドを作成しようとしています。しかし、私はいくつかの問題に直面しています。コードは次のとおりです。
using System;
using System.IO;
using System.Net;
using System.Xml;
using System.Text;
using System.Collections.Generic;
namespace API{
public static class Retrive
{
// some variables
public static void CopyTo(this Stream input, Stream output)///Extension method
{
byte[] buffer = new byte[32768];
int read;
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write (buffer, 0, read);
}
}
public static void Main ()
{
string url = "https://";
string baseURL = "";
string authenticateStr = "";
try
{
///
}
catch (WebException e)
{
using (WebResponse response = e.Response)
{
////
}
}
} // end main()
} // end class
}//名前空間の終了
私が得ているエラーは
1) 拡張メソッドは最上位の静的クラスで定義する必要があります。「取得」はネストされたクラスです。
「取得」クラスが入れ子になった理由がわかりません。
2) 拡張メソッドは、非ジェネリックな静的クラスで定義する必要があります
これらの問題を解決するにはどうすればよいですか?私を助けてください。
ありがとうございました。