C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






How to access sealed class methods


Posted Date: 20 Jun 2008    Resource Type: Code Snippets    Category: C# Syntax
Author: RohitMember Level: Gold    
Rating: Points: 10



There are two ways to access the sealed class methods:

1. First way:

sealed class Class1
{
static Class1 m_instance = null;
public static Class1 Instance
{
get
{
if(m_instance == null)
{
m_instance = new Class1();
}
return m_instance;
}
}

//Public Method
public int Calculate(int a, int b)
{
return a + b;
}
}

and in the main class, you can simply get the Calculate method as

int i = Class1.Instance.Calculate(2,3)
//Output
i = 5;



2. Second Way:

sealed class Class1
{
//Public Method
public int Calculate(int a, int b)
{
return a + b;
}
}

//and in the main class, first instantiate the sealed class object
Class1 objClass = new Class1();

//and then you can simply get the Calculate method as
int i = objClass.Calculate(2,3)

//Output
i = 5;





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sealed class  .  Access sealed class  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Datagrid to Excel
Previous Resource: Send SMS to a Mobile Phone Using C#
Return to Discussion Resource Index
Post New Resource
Category: C# Syntax


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use