<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # typeof(C# 參考) 用于獲取類型的 **System.Type** 對象。 **typeof** 表達式采用以下形式: ``` System.Type type = typeof(int); ``` ## 備注 若要獲取表達式的運行時類型,可以使用 .NET Framework 方法 [GetType](https://msdn.microsoft.com/zh-cn/library/system.object.gettype.aspx),如以下示例中所示: ``` int i = 0; System.Type type = i.GetType(); ``` 不能重載 **typeof** 運算符。 **typeof** 運算符也能用于公開的泛型類型。具有不止一個類型參數的類型的規范中必須有適當數量的逗號。下面的示例演示如何確定方法的返回類型是否是泛型 [IEnumerable&lt;T&gt;](https://msdn.microsoft.com/zh-cn/library/9eekhta0.aspx)。假定此方法是 MethodInfo 類型的實例: ``` string s = method.ReturnType.GetInterface (typeof(System.Collections.Generic.IEnumerable<>).FullName); ``` ``` public class ExampleClass { public int sampleMember; public void SampleMethod() {} static void Main() { Type t = typeof(ExampleClass); // Alternatively, you could use // ExampleClass obj = new ExampleClass(); // Type t = obj.GetType(); Console.WriteLine("Methods:"); System.Reflection.MethodInfo[] methodInfo = t.GetMethods(); foreach (System.Reflection.MethodInfo mInfo in methodInfo) Console.WriteLine(mInfo.ToString()); Console.WriteLine("Members:"); System.Reflection.MemberInfo[] memberInfo = t.GetMembers(); foreach (System.Reflection.MemberInfo mInfo in memberInfo) Console.WriteLine(mInfo.ToString()); } } /* Output: Methods: Void SampleMethod() System.String ToString() Boolean Equals(System.Object) Int32 GetHashCode() System.Type GetType() Members: Void SampleMethod() System.String ToString() Boolean Equals(System.Object) Int32 GetHashCode() System.Type GetType() Void .ctor() Int32 sampleMember */ ``` 此示例使用 [GetType](https://msdn.microsoft.com/zh-cn/library/system.object.gettype.aspx) 方法確定用來包含數值計算的結果的類型。這取決于結果數字的存儲要求。 ``` class GetTypeTest { static void Main() { int radius = 3; Console.WriteLine("Area = {0}", radius * radius * Math.PI); Console.WriteLine("The type is {0}", (radius * radius * Math.PI).GetType() ); } } /* Output: Area = 28.2743338823081 The type is System.Double */ ``` ## C# 語言規范 有關詳細信息,請參閱 [C# 語言規范](https://msdn.microsoft.com/zh-cn/library/ms228593.aspx)。該語言規范是 C# 語法和用法的權威資料。 ## 請參閱 [System.Type](https://msdn.microsoft.com/zh-cn/library/system.type.aspx) [C# 參考](https://msdn.microsoft.com/zh-cn/library/618ayhy6.aspx) [C# 編程指南](https://msdn.microsoft.com/zh-cn/library/67ef8sbd.aspx) [C# 關鍵字](https://msdn.microsoft.com/zh-cn/library/x53a06bb.aspx) [is(C# 參考)](https://msdn.microsoft.com/zh-cn/library/scekt9xw.aspx) [運算符關鍵字(C# 參考)](https://msdn.microsoft.com/zh-cn/library/bewds7kc.aspx)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看