Dynamic code snippet c# visual studio

前端 未结 3 1243
我在风中等你
我在风中等你 2021-02-19 19:12

I am working on a WinForms project with some repetitive tasks everyday. So I thought creating code a snippet will help me out, but it works for fixed code only.

I want t

3条回答
  •  借酒劲吻你
    2021-02-19 19:54

    I think you can use the System.Reflection namespace combined with the System.CodeDom namespace to achieve what you want.

    You can use the classes in the System.Reflection namespace and the System.Type class to discover the assembly name, the namespace, the properties, the methods, the base class, and plenty of other metadata about a class or variable. You'll then use these metadata aquired from your starting/source classes (eg.your Form Classes) to generate code of your target classes (your business and data classes) using CodeDOM.

    Check this msdn link on How to: Create a Class using CodeDOM as a starting point.

提交回复
热议问题