The Base Classes In C#

There are huge collections of base classes in .Net, i.e. approximately 3400 classes and there are also a large number of namespaces that contain these classes. We can’t give you the complete coverage of these namespaces and base classes of .Net, but we’ll give you a quick summary of some of the more useful namespaces here.
 
Namespace Classes Contained
System Most fundamental classes that are frequently used. For example the class object, from which every other class is derived, is defined in System, as are the primitive data types int, string, double etc.
System.Reflection Classes that allow examination of the metadata that describes assemblies, objects and types. Also used for COM Interoperability.
System.IO Input and output, file handling etc.
System.Collections Arrays, lists, linked lists, maps and other data structures.
System.Web Classes that assist in the generation of web pages using ASP+
System.Net Classes to make requests over the network and Internet
System.Data ADO+ classes that make it easy to access data from relational databases and other data sources.
System.WinForms Classes to display controls for standalone (as opposed to web) windows applications.
Microsoft.Win32 Functions that was previously accessible mainly through the Win32 API functions, such as registry access.
 
There are many more namespaces, and the best way to learn about them and the classes they contain is to explore them yourself.
 
Practical Example:
 
Steps:
 
? Create windows project.
? Default namespace has been created.
? Add new namespace out of the scope of default namespace.
? Using created namespace name with using directive.
 
Form1.cs[Design]
 
img
 
Form1.cs
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using myClass;

namespace testCustomNamespace
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            textBox3.ReadOnly=true;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "" && textBox1.Text != "First Number")
            {
                if (textBox2.Text != "" && textBox2.Text != "Second Number")
                {
                    myClass.abc aa = new abc();
                    int res = aa.addnum(int.
Parse(textBox1.Text), int.Parse(textBox2.Text));
                    textBox3.ReadOnly = false;
                    textBox3.Text = res.ToString();
                }
                else
                {
                    MessageBox.Show("Please enter second number.", 
"eBIZ Tutorial", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBox2.Focus();
                }
            }
            else
            {
                MessageBox.Show("Please enter first number.",
"eBIZ Tutorial",MessageBoxButtons.OK,MessageBoxIcon.Information);
                textBox1.Focus();
            }
        }

        private void textBox1_Click(object sender, EventArgs e)
        {
            textBox1.SelectAll();
        }

        private void textBox2_Click(object sender, EventArgs e)
        {
            textBox2.SelectAll();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox1.Text = "First Number";
            textBox2.Text = "";
            textBox2.Text = "Second Number";
            textBox3.Text = "";
            textBox3.Text = "Click on Add button to find result.";
        }        
    }
}

namespace myClass
{
    class abc
    {
        public int addnum(int x, int y)
        {
            int c = x + y;
            return c;
        }
    }
}
 
Program.cs
 
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace testCustomNamespace
{
    static class Program
    {
        /// 

/// The main entry point for the application. ///

        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}
 
The Output is:
 
img