ToString() will throw exception for null values,Convert.ToString() will not throw any exception for null values.
difference between varchar and nvarchar
Nvarchar stores UNICODE data. If you have requirements to store UNICODE or multilingual data, nvarchar is the choice. Varchar stores ASCII data and should be your data type of choice for normal use.
What is the difference between Compile time Exception and Runtime Exception?
Compile time is where your compiler transforms your source code to a machine understandable language.
During the compile time, it processes through various stages:
Creation of Symbol table, Syntax analysis, Semantic analysis, Code optimization, Code Generation & Error Handling.
Creation of Symbol table, Syntax analysis, Semantic analysis, Code optimization, Code Generation & Error Handling.
Runtime is during the execution process(Eg: Page request is made. or looping through a variable instances, etc). Runtime errors are handles after the successful compilation.
Can abstract class be Sealed in C#?
An abstract class cannot be a sealed class because the sealed modifier prevents a class from being inherited and the abstract modifier requires a class to be inherited.
Best C# Practices to follow
- Always name things well.
- Make sure there is only one class per file.
- Always try to use properties instead of public variables.
- Write methods to make only one thing.
- Use public modifier only when necessary.
- Try to keep everything simple.
- Always be consistent.
- Use curly braces for if statement.
- Concatenate strings using “$”.
- Avoid global variables.(Make use of app.config file to declare global variables if needed).
Tell about static and instance class members?
- When a class member includes a static modifier,the member is called as static member.When no static modifier is present the member is called non-static or instance member.
- Static members are invoked using class name where as instance members are invoked using instances(objects) of the class.
- An instance member belongs to specific instance(object) of a class.If we create three objects of a class we have three sets of instance members in the memory, where as there will ever be only one copy of the static member,no matter how many instances of a class are created.
What is a Object?
An object is an entity that has Properties for identifying State, Methods for behavior, Events for depicting the change of State.
Data associated at any given instance of time is the state of an object.
Every object differs from other objects either by state or behavior.