- Posted On 9 June 2014
- In Interview Questions
This post is a third part of my C# interview question and answers for fresher and experienced. If you havent read my previous post do read here at PART1 and PART2. Below are some questions with their answers as an addtion to the previous posts. Hope you will like it.
What is the difference between string and System.String?
If you know how the CTS (Common Type System) of Common Language Runtime (CLR) works then you can easily understand the difference. System.String is data type of CTS and string is alias for System.String in C#.
What is the difference between const and readonly?
const keyword gets used to declare compile time constants and readonly keyword gets used to define runtime constants. By compile time you mean that value is immutable and known at the compile time. Another difference is as const is compile time constant it can habe only one value and i.e. too at declaration on the other hand readonly field can be initialized either at the declaration or in a constructor. Therefore, readonly fields can have different values depending on the constructor used.
What is InvariantCulture?
InvariantCulture property represents neither a neutral nor a specific culture. It is useful for storing data in culture independent format that will not be displayed directly to the users. It guarantees that you have stored a data in unchanged format which is known for you. It might be useful when data gets read or write by users from different cultures e.g. datetime formats. So you can remember InvariantCulture as it is associated with the English language but not with a country or region.
What is difference of int and uint?
Both int and uint are 32 bit integral types the difference is int is signed integral and uint is a unsigned integral i.e. int can have both negative and postive integral values but uint always has positive values in a range of 0 to 4,294,967,295.
What are the different kinds of parameters?
There are four kinds of parameters which are follows,
Value Parameter : This is a frequently used kind of parameter which is used for input parameter passing. Modification to a value parameter do not affect the argument that was passed for the parameter.
Reference Parameter : This kind of parameter is used for both input and output parameter passing.Modification to a value parameter affects the argument that was passed because during execution of the method, the reference parameter represents the same storage location as the argument variable.
Output Parameter : This kind of parameter is used for output parameter passing. An output parameter is similar to a reference parameter except that the initial value of the caller-provided argument is unimportant.
Parameter Array : This kind of paramter permits a variable number of arguments to be passed to a method. A parameter array is declared with the params modifier. Only the last parameter of a method can be a parameter array, and the type of a parameter array must be a single-dimensional array type.
Thanks for reading. I will keep sharing such interview questions with their answers in my future posts but you don't forget to share these with your friends and also let me know if you know more questions like these.
C# Interview questions and answers for freshers and experienced - Part One
C# Interview Questions & Answers for 1-3 years of experience. Collection of some fresher and experienced level interview questions.
C# Interview questions and answers for freshers and experienced - Part Two
In this second post I will share questions like Default Access Modifier for Class,Generics in C#,Static class inheritance is possible or not along with different types of JIT compiler.
How to Prepare for the interviews - Simple but important tips - Part 3 - Prepare for HR Round
In this third post of my interview tips series, I am going to share some tips about how to prepare for HR Round. Also about things to do and things to not to do during the same.
How to Prepare for the interviews - Simple but important tips - Part 1 - Resume Writing
In this post I will share some interview tips from my own personal experience which will help you to prepare for the interview. In part one I will cover how to design a resume which will put your first impression smartly.
How to Prepare for the interviews - Simple but important tips - Part 2 - Things that matter during interview
In this second post of my interview tips series, I am going to share some tips about how to behave during the interview. Also about how to prepare for the interview and maintain self confidence during the interview.