CSharp Interview Questions and Answers
Question - 1 : -
What is CLS (Common Language Specificaiton)?
Answer - 1 : -
It provides the set of specificaiton which has to be adhered by any new language writer / Compiler writer for .NET Framework. This ensures Interoperability. For example: Within a ASP.NET application written in C#.NET language, we can refer to any DLL written in any other language supported by .NET Framework. As of now .NET Supports around 32 languages.
Question - 2 : - Can you store multiple data types in System.Array?
Answer - 2 : - No.
Question - 3 : - What’s the difference between System.String and System.Text.StringBuilder classes?
Answer - 3 : - System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.
Question - 4 : - What’s the advantage of using System.Text.StringBuilder over System.String?
Answer - 4 : - StringBuilder is more efficient in cases where there is a large amount of string manipulation. Strings are immutable, so each time a string is changed, a new instance in memory is created.
Question - 5 : - What does the term immutable mean?
Answer - 5 : - The data value may not be changed. Note: The variable value may be changed, but the original immutable data value was discarded and a new data value was created in memory.
Question - 6 : - What’s the top .NET class that everything is derived from?
Answer - 6 : - System.Object.
Question - 7 : - Does C# support multiple-inheritance?
Answer - 7 : - No.
Question - 8 : -
Who is a protected class-level variable available to?
Answer - 8 : -
It is available to any sub-class (a class inheriting this class).
Question - 9 : - Are private class-level variables inherited?
Answer - 9 : -
Yes, but they are not accessible. Although they are not visible or accessible via the class interface, they are inherited.
Question - 10 : - Describe the accessibility modifier “protected internal”.
Answer - 10 : -
It is available to classes that are within the same assembly and derived from the specified base class.