C#:Creating Private Assembly

C#:Creating Private Assembly


Introduction:


This code-snippet is a specific example of my earlier article: C#-The Language : A Step Ahead Series-Part-IV. Private assemblies are lying in their individual folder(s) and these are only meant to their individual application(s). You can use this by adding their reference. The following code snippet, creating a private assembly:



/* This Example is a part of different
* examples shown in Book:
* C#2005 Beginners: A Step Ahead
* Written by: Gaurav Arora
* Reach at : <a href="www.msdotnetheaven.com">msdotnetheaven</a>*/

// File name : mathclass.cs

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

namespace CSharp.AStepAhead.privateAssemby
{

public class mathClass
{
protected int num1, num2, meth;
protected string result;

public mathClass()
{
}
public mathClass(int x, int y, int mathOperation)
{
if (mathOperation <= 0)
{
throw new Exception("Invalid Math Operation.\nPlease Enter as: \n1 Addition\n2 Substraction\n3 Multiply\n4 Divide\n5 Square");
break;
}
else
{
num1 = x;
num2 = y;
meth = mathOperation;
}
}

public override string ToString()
{
switch (meth)
{
case 1: //addition
{
result = num1.ToString() + " + " + num2.ToString() + " = " + Convert.ToString(num1 + num2);
break;
}
case 2: //substraction
{
result = num1.ToString() + " - " + num2.ToString() + " = " + Convert.ToString(num1 - num2);
break;
}
case 3: //multiply
{
result = num1.ToString() + " * " + num2.ToString() + " = " + Convert.ToString(num1 * num2);
break;
}
case 4: //division
{
result = num1.ToString() + " / " + num2.ToString() + " = " + Convert.ToString(num1 / num2);
break;
}
case 5: //addition
{
result = "Square of " + num1.ToString() + " = " + Convert.ToString(num1 * num1);
result += "Square of " + num2.ToString() + " = " + Convert.ToString(num2 * num2);
break;
}
}
return result;
}
}
}


Article by Gaurav Aroraa
Gaurav is a Microsoft Technology Specialist professional. He has awarded lifetime membership from Computer Society of India (CSI). He has more than 13yrs of experience in the industry. Currently, he is working in the capacity of Solution Architect with an MNC. He is serving to the various communities since 1999.

Follow Gaurav Aroraa or read 157 articles authored by Gaurav Aroraa

Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: