Hii nauna,
First create a class library project. The add a class inside it and write the method.
Once code done build your project.
Then you will be able to see the dll file inside the bin folder.
Now you are ready to use it by adding the reference to the Web, Windows or console application.
Please refer below sample.
Class Library
C#
public class Math
{
public decimal Sum { get; set; }
public void Add(decimal x, decimal y)
{
Sum = x + y;
}
}
HTML
<asp:TextBox ID="txtX" runat="server"></asp:TextBox>
<asp:TextBox ID="txtY" runat="server"></asp:TextBox>
<asp:Button Text="Add" runat="server" OnClick="OnAdd" />
<hr />
<asp:Label ID="lblSum" runat="server" />
Code
C#
protected void OnAdd(object sender, EventArgs e)
{
Data.Math math = new Data.Math();
math.Add(Convert.ToDecimal(txtX.Text), Convert.ToDecimal(txtY.Text));
lblSum.Text = math.Sum.ToString();
}