- .NET Standard 2.0 Cookbook
- Fiqri Ismail
- 339字
- 2021-06-25 22:11:32
How it works...
If you have a closer look at the recipe we just completed, we have used a solution created from a previous recipe. In a real-world application, this is a day-to-day process. From steps 1 to 7, we opened an existing solution that contained the class library from the previous recipe and added a Classic Windows Forms application to the solution.
In steps 8 to 11, we prepared the Windows Form projects. Proper naming of the components and files is good practice. Even though this is a small application, proper naming is a good discipline. Steps 12 to 14 are the most important steps in this recipe. In these steps, we have added our class library to the Windows project as a reference. Now you can access all the public methods given by the class library from your Windows application.
In steps 15 to 17, we have added code to the button click event of HelloButton. Double-clicking on a component will get you to the C# code of the Windows form. Visual Studio will generate the code for you. In this case, it's the button click event. The default event of a component will vary depending on the component you have selected. In step 17, we created a variable to hold the instance of the HelloWorld class from the class library created. Then, we created another variable to hold the user input to the text box. The last line of code will call the HelloWorld.SayHello(string name) method with the string parameter supplied from the variable created in the previous line of code. Finally, a default message box will display the string returned from the SayHello(string name) method from the HelloWorld class.
Step 19 will execute the default project, in this case, our Windows-based application. Sometimes, if the class library project is selected as the default project, Visual Studio will complain that you cannot execute this sort of project. So make sure you have selected the Windows project as the default startup project.
- Boost.Asio C++ Network Programming(Second Edition)
- Implementing Modern DevOps
- Python快樂編程:人工智能深度學習基礎
- 程序員考試案例梳理、真題透解與強化訓練
- Visual C++串口通信技術詳解(第2版)
- INSTANT OpenNMS Starter
- 微信小程序項目開發實戰
- Learning Three.js:The JavaScript 3D Library for WebGL
- 深入淺出React和Redux
- Learning Apache Cassandra
- Python深度學習原理、算法與案例
- C語言程序設計
- HTML5游戲開發實戰
- Android應用程序設計
- Zend Framework 2 Cookbook