Series: Subject: Topic:

C# Interview Questions

Showing Questions 1 - 20 of 528 Questions
First | Prev | | Next | Last Page
Sort by: 

In a multilevel hierarchy how are the constructors are called

Asked By: Interview Candidate | Asked On: Jan 1st, 2006

A) topdownb) bottomupc) none

Answered by: Sunil on: Aug 31st, 2014

TOPDOWN is the correct answer. Always base class constructor is called before a sub-class constructor gets called. So, if a class is higher in the class hierarchy, then it will always get called be...

Answered by: narendra on: Aug 14th, 2014

"c# class Program { public class BaseClass { public BaseClass() { Console.WriteLine("Base class constructor"); ...

Advantages of static class over class ?

Asked By: sambomb3 | Asked On: Jun 24th, 2014

When to use static class and when to use normal class ?

Answered by: Sunil on: Aug 31st, 2014

WHEN SHOULD WE DO THIS: When we have a normal class and its methods being used very frequently in a given app, then it would speed up things if we made this class a static class with static methods. T...

Answered by: Knoxille_25 on: Aug 19th, 2014

A static class can make your implementation simpler and faster because you do not have to create an object in order to invoke its methods. It is useful to organize the methods inside the class in a meaningful way, such as the methods of the Math class in the System namespace.

How do you make a class not instantiable

Asked By: Interview Candidate | Asked On: Jan 1st, 2006

A) making class as abstractb) having a priVATe constructorc) making the class sealedd) both a & b

Answered by: Knoxille_25 on: Aug 19th, 2014

C) Making the class as sealed.

Answered by: BoYuan on: Jul 30th, 2014

The answer is A. For B, we cannot instantiate the class if there is only one constructor and that only constructor is private, otherwise, if there is at least one constructor is public, then that c...

What are constructors in .Net

Asked By: Bhanu | Asked On: Jun 21st, 2013

Answered by: Knoxille_25 on: Aug 19th, 2014

Constructs the value of data members of the class.

Answered by: Huy on: Jul 15th, 2014

Constructors are simply methods inside a class. These methods however has the SAME name as the class and are executed automatically whenever the class is instantiated. Parametrized constructors takes in arguments, while a default or parameter less constructor takes in no argument

How can I set formatting defaults to a chart's series, before populating data to the chart. For example for each chart there must be a different color for each name series like that. Is there any method...

Asked By: vijayan_kiran | Asked On: May 12th, 2006

Answered by: Huy on: Jul 15th, 2014

If youre using C#, simply select property SERIES, select the Series youre setting up, then set its properties. Each Series will have their own properties. But I suppose it only works if you know in advance how many series youre using.

How to handle exceptions without using try catch finally

Asked By: Nitesh | Asked On: Sep 27th, 2006

Answered by: Chandrashekhar Upadhyay on: Nov 16th, 2013

Using (SqlConnection con = new SqlConnection())
catch (Exception ex)

Answered by: vpote on: Apr 15th, 2013

The best way to do this would be doing the same in global.asax application_error method.


How can I check whether a dataset is empty or not in c#.Net

Asked By: Ravinder Nain | Asked On: Feb 2nd, 2006

Answered by: Chandrashekhar on: Nov 16th, 2013

DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(sqlString, sqlConn);

It is work i sure

Answered by: Bucked Naked on: Sep 11th, 2013

Wrong. Try this for better results:

  1. DataSet ds = <get a dataset somehow>;
  2. if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows > 0)
  3. {
  4.     // There is something in the DataSet.
  5. }

Second maximum number

Asked By: tmounika | Asked On: Nov 1st, 2012

How to find out second maximum number in c#?

Answered by: Werty on: Nov 10th, 2013

For example."c# int[] t = new int[5]; int max= 0,max2=0; Random rnd = new Random(); for (int i = 0; i < t.Length; i++) { t[i] = rnd.Next(10)...

The following code fails. Why?

Asked By: Farhan | Asked On: Nov 12th, 2007

Int a = 5; int b = 5; object oa = a; object ob = b; debug.Assert(oa == ob, "oa is not equal ob");

Answered by: chidski on: Oct 17th, 2013

Given code fails bcoz. debug result is wrong.. Please see below int a = 5; int b = 5; object oa = a; object ob = b; Debug.Assert(oa != ob...

Answered by: iaskalyani45 on: Jan 18th, 2013

Nice answer peter

When to use string classes

Asked By: sushil_gupta | Asked On: Jan 17th, 2011

When we have string builder which are mutable why we need immutable string classes in c#.

Answered by: Denial on: Aug 14th, 2013

String: String are immutable that is every time you make changes to a string object, the string is destroyed and a new string is created with modifications you applied to previous string. All this is ...

Answered by: Sivavt on: Mar 25th, 2012

String is immutable, meaning, if there is any change in the string value, run time allocates new memory & assign it to the string reference. For the programmer, it looks like the same string but inter...

Find substring in string

Asked By: yrs_abhishek | Asked On: Apr 10th, 2013

Hi All, I have written the below program to find the substring in the string. in case one word coming multiple time how to handle this situation ? the below program retuning -1 as position which is wrong.

  1. Input ("abhijit" , "jit")
  2. public int FindSubString(string strSuper, string strSub)
  3.         {
  4.             char[] charSuper = strSuper.ToCharArray();
  5.             char[] charSub = strSub.ToCharArray();
  7.             //int position = -1;
  8.             for (int i = 0; i <= charSuper.Length - charSub.Length; i++)
  9.             {
  10.                 int counter = 0;
  11.                 for (int J = 0; J < charSub.Length; J++)
  12.                 {
  13.                     if (charSuper[i] != charSub[J])
  14.                         continue;
  15.                     else
  16.                     {
  17.                         i++;
  18.                         counter++;
  19.                     }
  20.                 }
  21.                 if (counter == charSub.Length)
  22.                     position = i - charSub.Length;
  23.             }
  24.             return position;            
  25.         }
How to fixi it ?

Answered by: Kanwarjeet Yadav on: Aug 7th, 2013

Find Substring in string"c# public static bool substr(string mainstr, string str) { char[] main = mainstr.ToCharArray(); char[] sub = st...

Which of the following statements is not true for interfaces

Asked By: Interview Candidate | Asked On: Jan 1st, 2006

A) interface definitions does not have implementationb) interfaces must be declared as publicc) interfaces can be instantiatedd) interface does not have constructorsexplanation: interfaces can only be implemented by inheriting and they can not be instantiated

Answered by: TheDentist on: Apr 23rd, 2013

C is the correct answer. Interfaces dont have constructors so they cant be instantiated.

Answered by: michellext on: Sep 13th, 2012

C) Interfaces can be instantiated

Can we write dotnet console program in UNIX

Asked By: narsimhareddygajjela | Asked On: Jul 30th, 2012

Can we write dotnet console program in UNIX ? If yes give one example.

Answered by: TheDentist on: Apr 23rd, 2013

If you write in Java then the application will run in a JRE on UNIX but you have to compile the application on Windows first. Then deploy it to UNIX.

Answered by: vpote on: Sep 2nd, 2012

You can use mono .net for this

Which of the following statement is invalid with regards to constructor

Asked By: Interview Candidate | Asked On: Jan 1st, 2006

A) constructors should have the same name as class nameb) constructors have to be public so that class can be instantiatedc) constructors can not be overloadedexplanation: constructors can be overloaded with different parameters

Answered by: tmounika on: Nov 1st, 2012

All the three statements are true...

Answered by: Viky on: Oct 4th, 2012

The correct answer is B: as constructors need not be public we can have private constructors also for instance a singleton object has a private constructor

Reference variable of interface

Asked By: krish3636 | Asked On: Oct 26th, 2012

It is possible to create the reference variable of an interface which is 100% abstract in nature.Then why it is not possible to create a reference of an abstract class?

If a.Equals(b) is true then a.Gethashcode & b.Gethashcode must always return same hash code

Asked By: Interview Candidate | Asked On: Jan 1st, 2006

A) trueb) false

Answered by: Alexandre on: Oct 13th, 2012

Not necessarily. Actually GetHashCode() can always return the same value... :-) Say "1". And everything will work well. Just Hashtable with such a key will not be efficient. Keys in the hashtable are ...

Answered by: Deadbeef66 on: Oct 29th, 2011


Both Equals() and GetHashCode() can be overridden by the developer for user-defined classes, so there is no guaranteed behavior.

How to clear screen using c# console application...?Like clrscr() in c++..!

Asked By: Kannan | Asked On: Nov 22nd, 2006

Answered by: Anuj Malik on: Oct 5th, 2012

Console.Clear(); its work absolute in c# "c# using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication9 { class stud...

Answered by: amreenkhader on: Jan 20th, 2012

To clear the screen we can use the clrscr() command followed by ; to clear the input given to the program

Define reflection

Asked By: kritisrivastava11 | Asked On: Sep 5th, 2012

What is reflection and assembly?

Answered by: Poornima on: Sep 12th, 2012

Fetching the assembly information at runtime

Wap on 3d matrix by using random function print o/p in a file.

Asked By: k.sampath kumar | Asked On: Jun 1st, 2012

Wap on 3d matrix by using random function print in a file. find the prime numbers from out put of above program. find the even numbers from o/p of 1st program. find the odd numbers from o/p of 1st program.

Program on 3d matrix using random function print the o/p in file.

Asked By: k.sampath kumar | Asked On: Jun 1st, 2012

Program on 3d matrix using random function print the o/p in file find the even,odd,prime numbers from above output file. please do needful help thank you

First | Prev | | Next | Last Page





twitter fb Linkedin GPlus RSS


Interview Question

 Ask Interview Question?


Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.