.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Interview Question >> C# >> Post New Question Subscribe to Interview Questions

C# provides a default constructor for me. I write a constructor that takes a string as a parameter, but want to keep the no parameter one. How many constructors should I write?

Posted By :Shashi Ray     Posted Date :September 08, 2008    Points :10   Category :C# 
The answer is TWO of the above questions


How to find data with generics list in VB.NET (Write code).

In the code example below, the function "FindData" will return list("sublist") of the objects having matchingKey same as viewstate value.
Dim sublist As List(Of MyClass)
sublist = allClient.FindAll(AddressOf FindData) 'sublist will contain objects matching specified matching condition

Function FindData(ByVal b As MyClass) _
As Boolean
If (b.matchingKey = CInt(ViewState("matchingKey "))) Then 'matching condition
Return True
Return False
End If
End Function (More...)

Write and justify output of - select nullif('test','test')

The output will be - NULL
Justification : nullif returns NULl if given two arguments are same else returns the first specified argument. So, for the given SQL, output will be NULL. (More...)

You can also find related Interview Question to C# provides a default constructor for me. I write a constructor that takes a string as a parameter, but want to keep the no parameter one. How many constructors should I write?  below: 

How you will write a Connection String in web.Config fiel?

Ans) Then write below lines of code:

add name="sqlconnectionstring" connectionString="Data Source=INTHIYAAZ;Initial Catalog=DB;User ID=sa;Password=sa" />

Can you write a class without specifying namespace? Which namespace does it belong to by default??

Yes, you can, then the class belongs to global namespace which has no name. For commercial products, naturally, you wouldn't want global namespace (More...)

Difference between type constructor and instance constructor? What is static constructor, when it will be fired? And what is its use?

(Class constructor method is also known as type constructor or type initializer)
Instance constructor is executed when a new instance of type is created and the class constructor is executed after the type is loaded and before any one of the type members is accessed. (It will get executed only 1st time, when we call any static methods/fields in the same class.) Class constructors are used for static field initialization. Only one class constructor per type is permitted, and it cannot use the vararg (variable argument) calling convention. (More...)

What is Private Constructor? and it's use? Can you create instance of a class which has Private Constructor?

When a class declares only private instance constructors, it is not possible for classes outside the program to derive from the class or to directly create instances of it. (Except Nested classes)
Make a constructor private if:

1) You want it to be available only to the class itself. For example, you might have a special constructor used only in the implementation of your class' Clone method.

2) You do not want instances of your component to be created. For example, you may have a class containing nothing but Shared utility functions, and no instance data. Creating instances of the class would waste memory. (More...)

Constructor and Destructor


1. The Constructor is the first method that is run when an instance of a type is created. In visual basic a constructor is always Sub new ().

2. Constructor are use to initialize class and structure data before use. Constructor never returns a value and can be overridden to provide custom initialization functionality.

3. The constructor provides a way to set default values for data or perform other necessary functions before the object available for use.

Destructors are called just before an object is destroyed and can be used to run clean-up code. You can't control when a destructor is called. (More...)

What is 'Write-ahead log' in Sql Server 2000 ?

Before understanding it we must have an idea about the transaction log files. These files are the files which holds the data for change in database .
Now we explain when we are doing some Sql Server 2000 query or any Sql query like Sql insert query,delete sql query,update sql query and change the data in sql server database it cannot change the database directly to table .Sql server extracts the data that is modified by sql server 2000 query or by sql query and places it in memory.Once data is stores in memory user can make changes to that a log file is gernated this log file is gernated in every five mintues of transaction is done. After this sql server writes changes to database with the help of transaction log files. This is called Write-ahead log. (More...)

What is a private constructor? Where will you use it?

When you declare a Constructor with Private access modifier then it is called Private Constructor. We can use the private constructor in singleton pattern.

If you declare a Constructor as private then it doesn't allow to create object for its derived class, i.e you loose inherent facility for that class. (More...)

Is it possible to set SessionState to readonly mode? Readonly mode means, we can only read data from session but we can not write any data in session variable?

Yes, it is possible.
EnableSessionState property has a value "Readonly" which actually makes the session state read only.

Thanks. (More...)

Can we pass more than one querystring parameter with hyperlink in .aspx file?

Yes we can.
Code can be like,
NavigateUrl='<%# "Page.aspx?param1=" & _
DataBinder.Eval(Container.DataItem, "param1") & _
"¶m2=" & DataBinder.Eval(Container.DataItem, "param2") %>'
Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend