Go on File -- New -- Project -- choose Class library -- Give your library name--ok
using System;
namespace library
{
public class lib
{
static public int sum(int a, int b)
{
return (a + b);
}
}
}
Now call it in basic program :
For setting
output
Enter number for a:
400
Enter number for b:
234
Sum is:634
using System;
namespace library
{
public class lib
{
static public int sum(int a, int b)
{
return (a + b);
}
}
}
- Then compile it
Go on File -- New -- Project -- choose Console Application -- Give your
Console Application _name--ok
For setting
Go on Project -- Add Reference -- Browse -- choose location where Console Application save -- bin-- Debug-- library_name.dll
using System;
namespace class_sum_library
{
class Program
{
static void Main(string[] args)
{
int a, b, c;
Console.WriteLine("Enter number for a:");
a = int.Parse(Console.ReadLine());
Console.WriteLine("Enter number for b:");
b = int.Parse(Console.ReadLine());
c = a + b;
library.lib.sum(a, b);
Console.WriteLine("Sum is:" + c);
Console.ReadKey();
}
}
}
output
Enter number for a:
400
Enter number for b:
234
Sum is:634
No comments:
Post a Comment