19th Day
Hey Guys, I hope that you are Enjoying with my blogs in previous block we studied basic of C#, Its Installation, IL code by just in time make it machine code and Today's we will study about Basic concepts of C#, Class Libraries and Reusability.
- .NET is a free, cross-platform, open source developer platform for building many different types of applications.
- .NET Core is a cross-platform .NET implementation for websites, servers, and console apps on Windows, Linux, and macOS.
- With .NET, you can use multiple languages, editors, and libraries to build for web, mobile, desktop, games, and IoT.
- So lets create one console app(.NET core) project for better understanding to this concept.
- It is an exe i.e executable. we can double click and execute this folder.
- Build now and right click on console app open as an explorer go to bin folder and will get exe folder.
- Input:(Program.cs)
using System;using ClassLibrary1;namespace ConsoleApp2{class Program{static void Main(string[] args){Class1 x = new Class1();// we can call here to class1Console.WriteLine(x.Add(10,20));// here we giving parameter to add functionConsole.WriteLine("Hello World!");Console.Read();}}}
- To make DLL, Will have to create a Class library.
- DLL stands for dynamic link library it is library that contains function and codes that can used by more than one program at a time. Once we have created DLL we can use in many application.
- Input:(Class1.cs)using System;namespace ClassLibrary1{public class Class1{public int Add(int num1, int num2){return num1 + num2;}}}
- This code we can execute but can't link it.
- After build it, If we want to see DLL file go to its bin folder then executable file not will show , it show dll(dynamic link library) like given below
- We can't run this folder by double click because its not an executable it is Dynamic link library.so we can call to its function from another class.
- For reference to console app ,go to right side-> right click on dependency -> add project reference-> class library.
- Assembly has two types of library 1. Exe 2. DLL.
- Output:
Must refer this videos for more details:
ليست هناك تعليقات:
إرسال تعليق