奶头挺立呻吟高潮av全片,成人试看120秒体验区,性欧美极品v,A片高潮抽搐揉捏奶头视频

C語言

運算符關鍵字typeof的使用

時間:2024-12-27 14:37:43 C語言 我要投稿
  • 相關推薦

運算符關鍵字typeof的使用

  引導語:C語言是一種計算機程序設計語言,它既具有 高級語言的特點,又具有 匯編語言的特點。以下是小編整理的運算符關鍵字typeof的使用,歡迎參考閱讀!

  用于獲取類型的 System.Type 對象。typeof 表達式采用以下形式:

  System.Type type = typeof(int);

  備注

  若要獲取表達式的運行時類型,可以使用 .NET Framework 方法 GetType,如以下示例中所示:

  int i = 0;

  System.Type type = i.GetType();

  不能重載 typeof 運算符。

  typeof 運算符也能用于公開的泛型類型。具有不止一個類型參數的類型的規范中必須有適當數量的逗號。下面的示例演示如何確定方法的返回類型是否是泛型 IEnumerable<(Of <(t>)>)。假定此方法是 MethodInfo 類型的實例:

  string s = method.ReturnType.GetInterface

  (typeof(System.Collections.Generic.IEnumerable<>).FullName

  示例

  C#

  public class SampleClass2

  {

  public int sampleMember;

  public void SampleMethod() {}

  static void Main()

  {

  Type t = typeof(SampleClass);

  // Alternatively, you could use

  // SampleClass obj = new SampleClass();

  // 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:

  System.Type GetType()

  System.String ToString()

  Boolean Equals(System.Object)

  Int32 GetHashCode()

  Members:

  System.Type GetType()

  System.String ToString()

  Boolean Equals(System.Object)

  Int32 GetHashCode()

  Void .ctor()

  Void .ctor(Int32, System.String)

  System.String name

  Int32 id

  */

  此示例使用 GetType 方法確定用來包含數值計算的結果的類型。這取決于結果數字的存儲要求。

  C#

  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

  */

【運算符關鍵字typeof的使用】相關文章:

運算符關鍵字as的使用09-25

c#運算符關鍵字is的使用10-30

java語言運算符的使用10-02

Java中運算符的使用10-17

java的import關鍵字的使用08-17

C語言關鍵字const的使用09-02

C語言的關鍵字define的使用08-03

C語言的關鍵字enum的使用09-24

C語言關鍵字static的使用09-15

主站蜘蛛池模板: 清流县| 怀化市| 淄博市| 江油市| 红原县| 安岳县| 随州市| 丰宁| 沛县| 容城县| 邯郸县| 松江区| 沐川县| 诸城市| 北海市| 罗城| 德格县| 平顶山市| 襄垣县| 中江县| 余江县| 襄樊市| 临朐县| 永清县| 东宁县| 托克托县| 苗栗县| 尚志市| 建昌县| 城口县| 衡东县| 南江县| 类乌齐县| 巴塘县| 吴桥县| 龙海市| 观塘区| 东辽县| 靖宇县| 涞水县| 平远县|