C# Passing a class type as a parameter

后端 未结 6 1715
清酒与你
清酒与你 2021-02-10 00:49

This for C#? Passing Class type as a parameter

I have a class adapter that implements an Interface. I want to fill an array structure with MyFooClass instances where M

6条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-10 01:21

    The method:

    public void FillWsvcStructs(DataSet ds) where T : IElemRequest, new() {
        ...
        IElemRequest req = new T();
        ...
    }
    

    Calling the method:

    FillWsvcStructs(ds);
    

提交回复
热议问题