Vous êtes sur la page 1sur 4

5/9/2017 WrapperClassinC#

In Focus

Who is a Microsoft Regional Director?
Wrapper Class in C#
Ask a Question Contribute

Sourav Kayal Jun 23 2013 Blog

6 1 96.3k

Download 100% FREE Spire Oce APIs

Let's learn wrapper class today. Below is the formal bookish definition of Wrapper class.

A wrapper class is any class which "wraps" or "encapsulates" the functionality of

another class or component. These are useful by providing a level of abstraction from the

implementation of the underlying class or component;

Not much clear , Right ?

Ok, let me give example from my experience. I have a class for TAX calculation containing method to calculate TAX, and my
another class called SALARY calculator is there. Now to calculate salary I want to use TAX calculator class. And my interest is
that I will not disclose to other class How I am calculating TAX?. Then I will simply wrap my TAX calculator class by SALARY
class.

components. Have a look of below code. Though it's another example one.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Data.SqlClient;
using System.Data;
using System.Diagnostics;

namespace BlogProject
{

class Wrapper //Wrapper Class
{
class InnerClass //Inner Class
{
public Int32 ProcessDataint Val
{
http://www.csharpcorner.com/blogs/wrapperclassincsharp1 1/4
5/9/2017 WrapperClassinC#

In
Focus return Val + 1;

Who is a} Microsoft Regional Director?

}
Ask a Question Contribute
public Int32 CallRapper
{
Wrapper.InnerClass wpr = new Wrapper.InnerClass; // Internally call to Wrapper class.
return wpr.ProcessData100;
}
}

class Program
{
static void Mainstring[] args
{
Wrapper w = new Wrapper;
Console.WriteLine"Data Process by inner class and show by Wrapper Class:" + w.CallRapper;
Console.ReadLine;
}
}
}
Download 100% FREE Spire Oce APIs

Sourav Kayal

Visit my personal blog for latest and exciting articles of .NET/C#/Angular.Js and many more
http://ctrlcvprogrammer.blogspot.in/
http://ctrlcvprogrammer.blogspot.in/

31 8.6m 2

6 1

Type your comment here and press Enter Key (Minimum 18 characters)

thanks
sushil hadage Mar 04, 2015
1405 2 0 1 0 Reply

Comment Using

http://www.csharpcorner.com/blogs/wrapperclassincsharp1 2/4
5/9/2017 WrapperClassinC#

In Focus
0Comments Sortby Oldest
Who is a Microsoft Regional Director?

Ask a Question Contribute


Addacomment...

FacebookCommentsPlugin

File APIs for .NET


Aspose are the market leader of .NET APIs for le business formats natively work with
DOCX, XLSX, PPT, PDF, MSG, MPP, images formats and many more!

LATEST BLOGS
Table With Sorting Using AngularJS

Microsoft Hololens Helps Surgeons To Perform Spinal Surgeries

Top Navigation Bar Using XAML

How to Create A Simple Program For Hiding Folders with C#

Develop Games Easily Using Unity

Key Notes To WCF

Merits Of WCF Over Web Service And .NET Remoting Service

Given String Display From Dialogue Box Using ASP.NET .aspx

Find List Of Tables Used In Stored Procedure Using Types Of Joins

Resolving "Cannot Connect To .\sqlexpress Using SQL Server Authentication"

View All

Follow@csharpcorner 91.4Kfollowers

http://www.csharpcorner.com/blogs/wrapperclassincsharp1 3/4
5/9/2017 WrapperClassinC#

In Focus
C#Corner
Who is a Microsoft Regional Director?
1,284,200likes

Ask a Question Contribute

LikePage LearnMore

6friendslikethis

Philadelphia
New York
London
Delhi

Join C# Corner
A community of 2.3 million developers worldwide.

Enter your email address Sign Up

Learn ASP.NET MVC Learn ASP.NET Core Learn Python Learn JavaScript Learn Xamarin
Learn Oracle More...
Home Events Consultants Jobs Career Advice Stories

About Us Contact Us Privacy Policy Terms Media Kit Sitemap Report a Bug FAQ
2017 C# Corner. All contents are copyright of their authors.

http://www.csharpcorner.com/blogs/wrapperclassincsharp1 4/4

Vous aimerez peut-être aussi