如何在QBFC10Lib c#上获取接口类的名称
本文关键字:取接口 获取 QBFC10Lib | 更新日期: 2023-09-27 18:21:04
在这个C#代码中,我希望输出的结果与相同
AccountantCopy
Address
AddressBlock
CompanyAddressBlockForCustomer
CompanyAddressForCustomer
...
TaxForm
Type
因此,如果我在示例中使用typeof():
Type MyType = typeof(ICompanyRet);
MemberInfo[] Mymemberinfoarray = MyType.GetInterfaces();
Console.Write("'nThere are {0} members in ",Mymemberinfoarray.GetLength(0));
Console.Write("{0}.", MyType.Name);
foreach (MemberInfo Mymemberinfo in Mymemberinfoarray)
{
if (Mymemberinfo.Name != null)
Console.Write("'n" + Mymemberinfo.Name);
}
结果:
There are 1 members in ICompanyRet.
IQBBase
ICompanyRet:中的此代码
using System.Runtime.InteropServices;
namespace QBFC10Lib
{
[Guid("089A0574-58A7-48AE-B17E-297095B9E311")]
[TypeLibType(4160)]
public interface ICompanyRet : IQBBase
{
[DispId(24)]
IAccountantCopy AccountantCopy { get; }
[DispId(7)]
IAddress Address { get; }
[DispId(8)]
IAddressBlock AddressBlock { get; }
[DispId(11)]
IAddressBlock CompanyAddressBlockForCustomer { get; }
[DispId(10)]
IAddress CompanyAddressForCustomer { get; }
[DispId(15)]
IQBStringType CompanyEmailForCustomer { get; }
[DispId(5)]
IQBStringType CompanyName { get; }
[DispId(19)]
IQBStringType CompanyType { get; }
[DispId(16)]
IQBStringType CompanyWebSite { get; }
[DispId(25)]
IDataExtRetList DataExtRetList { get; }
[DispId(20)]
IQBStringType EIN { get; }
[DispId(14)]
IQBStringType Email { get; }
[DispId(13)]
IQBStringType Fax { get; }
[DispId(17)]
IQBENFirstMonthFiscalYearType FirstMonthFiscalYear { get; }
[DispId(18)]
IQBENFirstMonthIncomeTaxYearType FirstMonthIncomeTaxYear { get; }
[DispId(4)]
IQBBoolType IsSampleCompany { get; }
[DispId(9)]
IAddress LegalAddress { get; }
[DispId(6)]
IQBStringType LegalCompanyName { get; }
[DispId(12)]
IQBStringType Phone { get; }
[DispId(21)]
IQBStringType SSN { get; }
[DispId(23)]
ISubscribedServices SubscribedServices { get; }
[DispId(22)]
IQBENTaxFormType TaxForm { get; }
[DispId(1)]
IObjectType Type { get; }
}
}
对不起,这是我的第一个问题。非常感谢。
您实际上想要检索接口的属性,而不是它实现的接口。
MyType.GetProperties()
应该把你要找的房产还给你。
Type MyType = typeof(ICompanyRet);
PropertyInfo[] properties = MyType.GetProperties();
Console.Write("'nThere are {0} properties in {1}", properties.Length, MyType.Name);
foreach (PropertyInfo property in properties)
{
Console.Write("'n" + property.Name);
}