2012-04-26 63 views
4

我剛開始學習vb.net。 但我無法找出System.Type類的位置。 我GOOGLE了,但無法找到任何答案。 這裏是我做的:Type類在哪裏?

Module m 
Sub Main(ByVal e as String()) 
Dim ass as Assembly = Assembly.LoadFrom(e(0)) 
Dim assobj as Type() = ass.GetTypes() 
For Each m As Type In assobj 
Console.WriteLine(m.Name) 
next 

我改變了目錄爲C:\ WINDOWS \ Microsoft.NET \框架\ V2.0.50727>並提供System.dll中作爲參數 但我無法找到Type類

那麼,Type類是什麼?

如果有什麼不對,請忽略我的無知。 謝謝。再次

您好, 我有一個問題,我上面提到的這件事的目的是使類似於Java的javap.exe實用

一個控制檯應用程序,如果你給的類全名作爲參數,那麼它應該打印大量的信息關於班級。

問題是 - 我怎麼知道要加載哪個.dll文件,取決於我輸入的類名(這就是我期望System.Type會在System.dll文件中的原因)

+0

http://msdn.microsoft.com/en-us/library/system.type.aspx說,這是在** mscorlib.dll **中。這有幫助嗎?否則,你的意思是「在哪裏」? – 2012-04-26 14:58:12

+0

感謝您的鏈接..我的意思是 - 如果它不是在System.dll中,那麼其他.dll文件可以在。現在我知道它在mscorlib.dll中。 – user1247808 2012-04-26 16:09:11

+0

@ user1247808在StackOverflow上,通常當答案對你有幫助時,你可以選擇一個你認爲是「答案」的答案,並用綠色複選標記來標記答案,將這個問題設置爲「已回答」 – 2012-04-26 19:02:33

回答

2

我用ILSpy(免費工具)來看看。它是在mscorlib.dll

+0

非常感謝。 – user1247808 2012-04-26 16:05:36

2

像Michal和Mr Lister表示它在mscorlib.dll。

我發現它雖然以不同的方式,如果把你的代碼

Dim assobj as Type() = ass.GetTypes() 

和Word類型,然後按右鍵點擊「轉到定義」(快捷鍵F12)

默認顯示是VB.net & C#略有不同。 (對我來說,反正)

對於VB.Net:

你會看到對象瀏覽器,你可以注意到類型是系統
Definition of Type in Object Browser

的成員,如果您單擊系統,您會注意到它是mscorlib的成員。如果您點擊mscorlib,那麼您可以看到DLL實際存儲的位置。

Definition of System in Object Browser


如果您使用的是C#,那麼你將看到:

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

using System.Diagnostics; 
using System.Globalization; 
using System.Reflection; 
using System.Runtime; 
using System.Runtime.InteropServices; 
using System.Security; 

namespace System 
{ 
    // Summary: 
    //  Represents type declarations: class types, interface types, array types, 
    //  value types, enumeration types, type parameters, generic type definitions, 
    //  and open or closed constructed generic types. 
    [Serializable] 
    [ClassInterface(ClassInterfaceType.None)] 
    [ComDefaultInterface(typeof(_Type))] 
    [ComVisible(true)] 
    public abstract class Type : MemberInfo, _Type, IReflect 
    { 
     //snip 
    } 
} 
+0

感謝您的信息 – user1247808 2012-04-26 16:09:33