Click here to Skip to main content
15,900,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello friends:

i have a class with name
C#
ReceiveMsgService()
{
-----------------------
-----------------------
-----------------------
}

i m performming some work there.

now i want to make a static object of ReceiveMsgService class in my other class.

so can u help me how can i define it in my other class?
mean a static object..
Posted
Updated 15-Dec-11 18:18pm
v2

First of all 'static' and 'object' really makes little sense.
Any static class cannot be instantiated. So you cannot create a static instance object of a normal class.

If you define your class as static
e.g.
C#
static class ReceiveMsgService()

you will be able to direcly access static members inside the other class.

Otherwise the only option you have is to create an instance -
ReceiveMsgService o = new ReceiveMsgService(); and then use it accordingly.
 
Share this answer
 
Comments
prince_rumeel 16-Dec-11 0:29am    
static ReceiveMsgService object = new ReceiveMsgService();

i created like this
and with no error.
is it ok?
static ReceiveMsgService object = new ReceiveMsgService();

and it is working fine.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900