user defined class libraries or Dlls

Posted by Ersudeep13 under .NET Framework on 4/29/2016 | Points: 10 | Views : 1721 | Status : [Member] | Replies : 1
Component--> A component is reusable piece of code and is in the form of DLL.

Once component is designed it can be reused from any kind of application like in console application or windows application or web application or device application etc.

Once a component is designed in any programming language of .net that can be reused from any other programming languages of .Net i.e. .Net components are or assemblies will provide language interoperability.
To create component in .Net, we use class libraries templates.
End user will never interact with some application will interact with component or DLL.

program for creating a Component / Assembly

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CLibMaths
{
public class Arithmatic
{
public int Num1, Num2, Result;
public int PNum1
{

set { Num1 = value; }
get { return Num1; }
}
public int PNum2
{
set { Num2 = value; }
}
public int PResult
{
get { return Result; }
}
public int Add()
{
Result = Num1 + Num2;
return Result;
}
public void Subtract()
{
Result = Num1 - Num2;
}
public void Multiply()
{
Result = Num1 * Num2;
}
public void Divide()
{
Result = Num1 / Num2;
}
}
}

ADD a new class with name ClsMathNumbers
Change the accessibility of the class to public and write following code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CLibMaths
{
public class ClsMathNumbers
{
public int Square(int x)
{
return x * x;
}
public int Cube(int x)
{
return x * Square(x);
}
public int Factorial(int x)
{
int R = 1;
for (int i = 1; i <= x; i++)
{
R = R * i;
}
return R;
}
}
}

Build the solution will create a DLL. this dll is known as .net component
to see the DLL go to the \bin\Debug folder of the application , you find the CLibMaths.dll




Responses

Posted by: Sheonarayan on: 4/29/2016 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
@Ersudeep13,

Thanks for your posts, looks like you have desire to share your knowledge and that is great. However Forums is not the place for this type of posts. Forums is mainly for question/answer of discussion on any topic.

I think code snippets may fit better for your purpose, kindly move this post into Code Snippets section and continue posting similar information in that section only.

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Ersudeep13, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response