What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 1509 |  Welcome, Guest!   Register  Login
 Home > Interview Questions > .NET Framework Interview Questions > Which Constructor gets fired first Stati ...

Which Constructor gets fired first Static or Non-Static while creating an object of a class?

Interview question and answer by: Kishork80 | Posted on: 3/19/2011 | Category: .NET Framework Interview questions | Views: 1911 | | Points: 40


Answer:

Static constructor will be fired first.
Ex:
class Test{

public Test(){
Console.WriteLine(" public Test()");
}
static Test(){
Console.WriteLine(" static Test()");
}
}
class Program{
static void Main(string[] args){
Test test = new Test();
Console.Read();
}
}


Output:
static Test()
public Test()

Asked In: Many Interviews | Alert Moderator 
Found interesting? Add this to:


 Responses

Posted by: Akiii | Posted on: 21 Mar 2011 11:26:51 AM | Points: 10 | Alert Moderator 

good one sir..

Thanks
Akiii

>> Write Response - Respond to this post and get points

Even more ... | Submit Interview Questions and win prizes!

More Interview Questions from Kishork80

Even more ... | Submit Interview Questions and win prizes!


About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/25/2013 7:24:27 PM