2011-07-22 5 views
4

.NET Frameworkのソースコードをダウンロードするだけです。http://referencesource.microsoft.com/netframework.aspx It's Net_4.msi。しかし、私はそれをインストールした後、IEnumeratorコードファイルを見つけることができません。 Net_4.msiにすべての.NETクラスが含まれていないのは不思議です。IEnumeratorのソースコードはどこですか?


更新: 回答をありがとうと混乱して申し訳ありません。

私はIEnumeratorの定義を求めていません。 "Net_4.msi"には、.Netクラス/インタフェースのソースコードファイルがすべて含まれている必要があります。 フォルダNet_4\Source\ndp\clr\src\BCL\System\Collectionsのように、IList.cs、ICollection.cs、IDictionary.cs、IEnumerable.csがあります。 これら4つのファイルは、それぞれIList、ICollection、IDictionary、およびIEnumerableソースコードファイルです。 this imageを参照してください。

IEnumerator.csファイルが見つかりません。 IEnumerator.csがどこにあるか知りたいだけです。 IEnumerator.csが "Net_4.msi"に含まれないのはなぜですか?

+0

loki2302は完全に右です。あなたの質問を編集することができますので、実際の問題をお手伝いすることができます。これはインターフェイスなので、実際の実装(String.GetEnumerator()の場合はCharEnumeratorクラス)を知っている必要があります。 –

+0

具体的には何をお探しですか?あなたは.Net Reflectorのような逆コンパイラを持っていますか? –

答えて

2

IEnumeratorはクラスではなく、インターフェイスです。コードはありません。

+1

インターフェイスには、少なくとも「それはキーワードを使用する」という意味でコードがあります。 @Ritch; –

+1

;あなたは賢明である。実装はありません。それはOPが探しているものです。 –

+0

どのようなコードですか?ちょうど定義ですか?これは、Visual Studioでメタデータを表示するときに使用できます。 – agibalov

5

lokiが指摘しているように、IEnumerator<T>は具体的なクラスではないため、実装されていません。あなたは少し周り狩りと直接あなたの質問に答えるためにan example of how to implement the interface for your custom type(s).

を見つけることができるしかし、それはがmscorlib.dllで定義され、これは全体の.NET 4.0のファイルです:

#region Assembly mscorlib.dll, v4.0.30319 
// C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll 
#endregion 

using System; 
using System.Collections; 

namespace System.Collections.Generic 
{ 
    // Summary: 
    //  Supports a simple iteration over a generic collection. 
    // 
    // Type parameters: 
    // T: 
    //  The type of objects to enumerate.This type parameter is covariant. That is, 
    //  you can use either the type you specified or any type that is more derived. 
    //  For more information about covariance and contravariance, see Covariance 
    //  and Contravariance in Generics. 
    public interface IEnumerator<out T> : IDisposable, IEnumerator 
    { 
     // Summary: 
     //  Gets the element in the collection at the current position of the enumerator. 
     // 
     // Returns: 
     //  The element in the collection at the current position of the enumerator. 
     T Current { get; } 
    } 
} 
+0

この逆コンパイルされたビューで失われるものは、 'T Current'は実際に' new T Current'として定義されています。 https://github.com/Microsoft/referencesource/blob/master/mscorlib/system/collections/generic/ienumerator.cs –

関連する問題