PC Review


Reply
Thread Tools Rate Thread

2 C# Class's Questions

 
 
deepak
Guest
Posts: n/a
 
      12th Sep 2010
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
(E-Mail Removed)
 
Reply With Quote
 
 
 
 
deepak
Guest
Posts: n/a
 
      12th Sep 2010
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
> (E-Mail Removed)

 
Reply With Quote
 
gerry
Guest
Posts: n/a
 
      13th Sep 2010
#1 - why ask - just try it. ( stack overflow )



"deepak" <(E-Mail Removed)> wrote in message
news:0D6934B0-3A02-4414-BC51-(E-Mail Removed)...
> 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
> (E-Mail Removed)



 
Reply With Quote
 
deepak
Guest
Posts: n/a
 
      2nd Oct 2010
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
> > (E-Mail Removed)

 
Reply With Quote
 
deepak
Guest
Posts: n/a
 
      2nd Oct 2010
Can anybody reply to my 2nd question... Is this possible through
delegtes?...i am waiting for your answers....

"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
> > (E-Mail Removed)

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Class questions Trust Me; I'm from the government Microsoft ASP .NET 3 5th Oct 2007 04:21 AM
SqlBulkCopy class questions... Jéjé Microsoft Dot NET Framework 0 14th Dec 2005 11:37 AM
Questions on HttpApplication class parez Microsoft ASP .NET 2 14th Oct 2005 06:26 PM
c# overriding class questions MattB Microsoft C# .NET 2 9th Jul 2004 04:02 PM
Using the pen class - Questions Tobias Froehlich Microsoft C# .NET 3 19th Sep 2003 05:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:56 PM.