TypeInfo.DeclaredMethods プロパティ
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
現在の型によって定義されたメソッドのコレクションを取得します。
public:
virtual property System::Collections::Generic::IEnumerable<System::Reflection::MethodInfo ^> ^ DeclaredMethods { System::Collections::Generic::IEnumerable<System::Reflection::MethodInfo ^> ^ get(); };
C#
public virtual System.Collections.Generic.IEnumerable<System.Reflection.MethodInfo> DeclaredMethods { get; }
member this.DeclaredMethods : seq<System.Reflection.MethodInfo>
Public Overridable ReadOnly Property DeclaredMethods As IEnumerable(Of MethodInfo)
現在の型によって定義されたメソッドのコレクション。
次の例では、.NET のリフレクション型とメンバーを使用して、継承されたメソッドとプロパティを含む型の Calendar メソッドとプロパティを取得し、コンソールに書き込みます。
C#
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using System.Text;
TypeInfo t = typeof(Calendar).GetTypeInfo();
IEnumerable<PropertyInfo> pList = t.DeclaredProperties;
IEnumerable<MethodInfo> mList = t.DeclaredMethods;
StringBuilder sb = new StringBuilder();
sb.Append("Properties:");
foreach (PropertyInfo p in pList)
{
sb.Append("\n" + p.DeclaringType.Name + ": " + p.Name);
}
sb.Append("\nMethods:");
foreach (MethodInfo m in mList)
{
sb.Append("\n" + m.DeclaringType.Name + ": " + m.Name);
}
Console.WriteLine(sb.ToString());
/* This code outputs the following text:
Properties:
Calendar: MinSupportedDateTime
Calendar: MaxSupportedDateTime
Calendar: AlgorithmType
Calendar: ID
Calendar: BaseCalendarID
Calendar: IsReadOnly
Calendar: CurrentEraValue
Calendar: Eras
Calendar: DaysInYearBeforeMinSupportedYear
Calendar: TwoDigitYearMax
Methods:
Calendar: get_MinSupportedDateTime
Calendar: get_MaxSupportedDateTime
Calendar: get_AlgorithmType
Calendar: get_ID
Calendar: get_BaseCalendarID
Calendar: get_IsReadOnly
Calendar: get_CurrentEraValue
Calendar: get_Eras
Calendar: get_DaysInYearBeforeMinSupportedYear
Calendar: get_TwoDigitYearMax
Calendar: set_TwoDigitYearMax
Calendar: Clone
Calendar: ReadOnly
Calendar: VerifyWritable
Calendar: SetReadOnlyState
Calendar: CheckAddResult
Calendar: Add
Calendar: AddMilliseconds
Calendar: AddDays
Calendar: AddHours
Calendar: AddMinutes
Calendar: AddMonths
Calendar: AddSeconds
Calendar: AddWeeks
Calendar: AddYears
Calendar: GetDayOfMonth
Calendar: GetDayOfWeek
Calendar: GetDayOfYear
Calendar: GetDaysInMonth
Calendar: GetDaysInMonth
Calendar: GetDaysInYear
Calendar: GetDaysInYear
Calendar: GetEra
Calendar: GetHour
Calendar: GetMilliseconds
Calendar: GetMinute
Calendar: GetMonth
Calendar: GetMonthsInYear
Calendar: GetMonthsInYear
Calendar: GetSecond
Calendar: GetFirstDayWeekOfYear
Calendar: GetWeekOfYearFullDays
Calendar: GetWeekOfYearOfMinSupportedDateTime
Calendar: GetWeekOfYear
Calendar: GetYear
Calendar: IsLeapDay
Calendar: IsLeapDay
Calendar: IsLeapMonth
Calendar: IsLeapMonth
Calendar: GetLeapMonth
Calendar: GetLeapMonth
Calendar: IsLeapYear
Calendar: IsLeapYear
Calendar: ToDateTime
Calendar: ToDateTime
Calendar: TryToDateTime
Calendar: IsValidYear
Calendar: IsValidMonth
Calendar: IsValidDay
Calendar: ToFourDigitYear
Calendar: TimeToTicks
Calendar: GetSystemTwoDigitYearSetting
*/
プロパティの DeclaredMethods 結果をフィルター処理するには、LINQ クエリを使用します。 ランタイムで生成されたリフレクション オブジェクトの場合 (たとえば、 の結果として)、 クラスの typeof(Object)
メソッドを使用して継承ツリーを RuntimeReflectionExtensions 走査できます。 カスタマイズされたリフレクション コンテキストのオブジェクトのコンシューマーは、これらのメソッドを使用できず、継承ツリー自体を走査する必要があります。
製品 | バージョン |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1 |
UWP | 10.0 |
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。