From: deepak on
Hi,

There are 2 Questions on C# Classes :->

Quest 1. What will be result of below program.
Class A {
A()
{
B objB = new B();
}
}
class B {
B()
{
A objA = new A();
}
}

}
static void Main(string[] args)
{

A objA = new A();
B objB = new B();



Quest 2. How can I call method written in Class B without creating instance
of
Class B i.e. without using B objB= new B();

Class A{ Class B: A{ Class C: B{
Class D:C{
public Calc() public Calc() public Calc()
public Calc()
{ { {
{
//// //// ////
////
return 1; return 2; return 3;
return 4;
} } }
}
} } }
}


- Deepak
kr.deepak123(a)gmail.com
From: deepak on
Actually Question 2 is not showed correctly which I am writing again to make
it clear

Class A{

public Calc()
{
////
return 1;
}
}

Class B: A{

public Calc()
{
////
return 2;
}
}

Class C: B{

public Calc()
{
////
return 3;
}
}

Class D: C{

public Calc()
{
////
return 4;
}
}



"deepak" wrote:

> Hi,
>
> There are 2 Questions on C# Classes :->
>
> Quest 1. What will be result of below program.
> Class A {
> A()
> {
> B objB = new B();
> }
> }
> class B {
> B()
> {
> A objA = new A();
> }
> }
>
> }
> static void Main(string[] args)
> {
>
> A objA = new A();
> B objB = new B();
>
>
>
> Quest 2. How can I call method written in Class B without creating instance
> of
> Class B i.e. without using B objB= new B();
>
> Class A{ Class B: A{ Class C: B{
> Class D:C{
> public Calc() public Calc() public Calc()
> public Calc()
> { { {
> {
> //// //// ////
> ////
> return 1; return 2; return 3;
> return 4;
> } } }
> }
> } } }
> }
>
>
> - Deepak
> kr.deepak123(a)gmail.com
From: Cubaman on
On Sep 12, 9:14 pm, deepak <dee...(a)discussions.microsoft.com> wrote:
> Actually Question 2 is not showed correctly which I am writing again to make
> it clear
>
> Class A{
>
>               public Calc()
>                {
>                  ////
>                 return 1;
>                }
>           }
>
> Class B: A{
>
>               public Calc()
>                {
>                  ////
>                 return 2;
>                }
>           }
>
> Class C: B{
>
>               public Calc()
>                {
>                  ////
>                 return 3;
>                }
>           }
>
> Class D: C{
>
>               public Calc()
>                {
>                  ////
>                 return 4;
>                }
>           }
>
> "deepak" wrote:
> > Hi,
>
> > There are 2 Questions on C# Classes :->
>
> >  Quest 1. What will be result of below program.
> >               Class A {                
> >                                 A()
> >                                   {
> >                                      B objB = new B();
> >                                  }    
> >                           }
> >                class B {
> >                                B()
> >                                   {
> >                                      A objA = new A();
> >                                  }    
> >                           }
>
> >                 }
> >               static void Main(string[] args)
> >               {
>
> >                A objA = new A();
> >                B objB = new B();
>
> >  Quest 2. How can I call method written in Class B without creating instance
> > of    
> >               Class B i.e. without using B objB= new B();
>
> >  Class A{                       Class B: A{               Class C: B{        
> >    Class D:C{
> >        public Calc()           public Calc()            public Calc()        
> >    public Calc()    
> >          {                          {                           {            
> >               {
> >              ////                    ////                          ////      
> >               ////
> >           return 1;                return 2;                return 3;        
> >      return 4;
> >           }                          }                               }      
> >                    }
> >          }                          }                           }            
> >                 }
>
> > - Deepak
> > kr.deepak...(a)gmail.com

Question 1: What do you mean with "result"? There won't be any
aoutput..

Question 2: Make your method static.

static class A{
static int Calc(){
return 1;
}
}


Later:
int a = A.Calc();
From: gerry on
#1 - why ask - just try it. ( stack overflow )



"deepak" <deepak(a)discussions.microsoft.com> wrote in message
news:0D6934B0-3A02-4414-BC51-330F3C752224(a)microsoft.com...
> Hi,
>
> There are 2 Questions on C# Classes :->
>
> Quest 1. What will be result of below program.
> Class A {
> A()
> {
> B objB = new B();
> }
> }
> class B {
> B()
> {
> A objA = new A();
> }
> }
>
> }
> static void Main(string[] args)
> {
>
> A objA = new A();
> B objB = new B();
>
>
>
> Quest 2. How can I call method written in Class B without creating
> instance
> of
> Class B i.e. without using B objB= new B();
>
> Class A{ Class B: A{ Class C: B{
> Class D:C{
> public Calc() public Calc() public Calc()
> public Calc()
> { { {
> {
> //// //// ////
> ////
> return 1; return 2; return 3;
> return 4;
> } } }
> }
> } } }
> }
>
>
> - Deepak
> kr.deepak123(a)gmail.com


From: deepak on
Can anybody reply to my 2nd question....Is this possible throuhg delegates..I
am waiting for your replies ASAP.

"deepak" wrote:

> Actually Question 2 is not showed correctly which I am writing again to make
> it clear
>
> Class A{
>
> public Calc()
> {
> ////
> return 1;
> }
> }
>
> Class B: A{
>
> public Calc()
> {
> ////
> return 2;
> }
> }
>
> Class C: B{
>
> public Calc()
> {
> ////
> return 3;
> }
> }
>
> Class D: C{
>
> public Calc()
> {
> ////
> return 4;
> }
> }
>
>
>
> "deepak" wrote:
>
> > Hi,
> >
> > There are 2 Questions on C# Classes :->
> >
> > Quest 1. What will be result of below program.
> > Class A {
> > A()
> > {
> > B objB = new B();
> > }
> > }
> > class B {
> > B()
> > {
> > A objA = new A();
> > }
> > }
> >
> > }
> > static void Main(string[] args)
> > {
> >
> > A objA = new A();
> > B objB = new B();
> >
> >
> >
> > Quest 2. How can I call method written in Class B without creating instance
> > of
> > Class B i.e. without using B objB= new B();
> >
> > Class A{ Class B: A{ Class C: B{
> > Class D:C{
> > public Calc() public Calc() public Calc()
> > public Calc()
> > { { {
> > {
> > //// //// ////
> > ////
> > return 1; return 2; return 3;
> > return 4;
> > } } }
> > }
> > } } }
> > }
> >
> >
> > - Deepak
> > kr.deepak123(a)gmail.com