What is the execution entry point for a C# console application?
How do you initiate a string without escaping each backslash?
what is c sharp
What is object-oriented programming (OOP) Language?
Explain about C# Language.
Types of comments in C#?
feature of C# language?
What is a Class?
What is object?
What is Constructors, explain with syntax
index value of the first element in an array?
Different between method overriding and method overloading?
Explain use of Abstract and Sealed Classes in C#?
What is Static Classes?
Explain Static Class Members.
Which are Access Modifiers available in C#?
Data Types in C#?
What are sealed classes in C#?
What are delegates?
What is the difference between a Struct and a Class?
What is difference between is and as operators in c#?
What are C# attributes and its significance?
What is a NullReferenceException and how do I fix it?
How to update the GUI from another thread in C#?
How to use reflection to call generic Method?
How to properly clean up Excel interop objects
Why are mutable structs evil?
How do you convert Byte Array to Hexadecimal String, and vice versa?
How do I calculate relative time?
What is the difference between a Field and a Property in C#?
Why is it important to override GetHashCode when Equals method is overridden?
How to force my .NET App to run as administrator on Windows 7?
Top reason to use C# language?
Types of Constructors
What is C#?
Can multiple catch blocks be executed?
What is the difference between public, static and void?
Define Constructors?
What is Jagged Arrays?
What is the difference between ref & out parameters?
What is the use of using statement in C#?
Can "this" be used within a static method?
What is difference between constants and read-only?
What is an interface class?
What are Custom Control and User Control?
What is the difference between Array and Arraylist?
What are the differences between System.String and System.Text.StringBuilder classes?
What's the difference between the System.Array.CopyTo() and System.Array.Clone() ?
How can we sort the elements of the array in descending order?
What's the difference between an interface and abstract class?
What is the difference between Finalize() and Dispose() methods?
What are circular references?
What are generics in C#.NET?
What is an object pool in .NET?
List down the commonly used types of exceptions in .Net?
What are Custom Exceptions?
How do you inherit a class into other class in C#?
What is the difference between method overriding and method overloading?
What are the different ways a method can be overloaded?
Why can't you specify the accessibility modifier for methods inside the interface?
How can we set class to be inherited, but prevent the method from being over-ridden?
What happens if the inherited interfaces have conflicting method names?
How to implement singleton design pattern in C#?
What is the difference between directcast and ctype?
Is C# code is managed or unmanaged code?
Famous Insurance company has a requirement to calculate the age of their customer based on the date of birth received as a string from the user.
Write a program that receives the customer date of birth in the format (dd-mm-yyyy).
Pass this value to a method, 'calculateAge' which returns the calculated age. Keep the method 'static'.
Method to implement:
public static int calculateAge(string dateOfBirth)
Sample Input :
Enter the date of birth (dd-mm-yyyy): 22-10-1984
Sample Output:
36
C SHARP IN GAMING?
C Sharp interview questions and answers on advance and basic C Sharp with example so this page for both freshers and experienced condidate. Fill the form below we will send the all interview questions on C Sharp also add your Questions if any you have to ask and for apply
in C Sharp Tutorials and Training course just send a mail on info@pcds.co.in in detail about your self.
Top C Sharp interview questions and answers for freshers and experienced
What is C Sharp ?
Answer :
Questions : 1 :: What is C Sharp Language?
C# is an elegant and type-safe object-oriented language that enables developers to build a variety of secure and robust applications that run on the .NET Framework. You can use C# to create...View answers
Questions : 2 :: What are namespaces, and how they are used?
Namespaces are used to organize classes within the .NET Framework. They dictate the logical structure of the code. They are analogous to Java packages, with the key difference being Java packages...View answers
Questions : 3 :: What is a constructor?
A constructor is a class member executed when an instance of the class is created. The constructor has the same name as the class, and it can be overloaded via different signatures. Constructors are...View answers
Questions : 4 :: What is the GAC, and where is it located?
The GAC is the Global Assembly Cache. Shared assemblies reside in the GAC; this allows applications to share assemblies instead of having the assembly distributed with each application. Versioning...View answers
Questions : 5 :: Why are strings in C# immutable?
Immutable means string values cannot be changed once they have been created. Any modification to a string value results in a completely new string instance, thus an inefficient use of memory and...View answers
Questions : 6 :: What is DLL Hell, and how does .NET solve it?
DLL Hell describes the difficulty in managing DLLs on a system; this includes multiple copies of a DLL, different versions, and so forth. When a DLL (or assembly) is loaded in .NET, it is loaded by...View answers
Questions : 7 :: How are methods overloaded?
Methods are overloaded via different signatures (number of parameters and types). Thus, you can overload a method by having different data types, different number of parameters, or a different order...View answers
Questions : 8 :: How do you prevent a class from being inherited?
The sealed keyword prohibits a class from being inherited.
Questions : 9 :: What is the execution entry point for a C# console application?
The Main method.
Questions : 10 :: How do you initiate a string without escaping each backslash?
You put an @ sign in front of the double-quoted string.
String ex = @"This has a carriage...View answers
Questions : 11 :: what is c sharp
C sharp is a programing language
Questions : 12 ::
Questions : 13 :: What is object-oriented programming (OOP) Language?
Object-oriented programming (OOP) is a programming language model organized around objects rather than "actions" and data rather than logic. Historically, a program has been...View answers
Questions : 14 :: Explain about C# Language.
C# is a OOPs language, .net framework use to compiled it, to generate machine...View answers
Questions : 15 :: Types of comments in C#?
Single line comments// for single line commentsMultiple line comments/* for multi line comments */XML tags comments/// XML tags displayed in a code...View answers
Questions : 16 :: feature of C# language?
Boolean ConditionsAutomatic Garbage CollectionStandard LibraryAssembly VersioningProperties and EventsDelegates and Events ManagementEasy-to-use GenericsIndexersConditional...View answers
Questions : 17 :: What is a Class?
a set or category of things having some property or attribute in common and differentiated from others by kind, type, or...View answers
Questions : 18 :: What is object?
Objects are created from Classes, in C#, is an instance of a class that is created dynamically. Object is also a keyword that is an alias for the predefined type...View answers
Questions : 19 :: What is Constructors, explain with syntax
A is special method of the class that will be automatically invoked when an instance of the class is created is called as constructor.Constructors are mainly used to...View answers
Questions : 20 :: index value of the first element in an array?
Questions : 21 :: Different between method overriding and method overloading?
In Overriding methods it will create two or more methods with same name and same parameter in different classes.while Overloading it will create more then one method with...View answers
Questions : 22 :: Explain use of Abstract and Sealed Classes in C#?
The abstract keyword enables you to create classes and class members that are incomplete and must be implemented in a derived class.The sealed keyword enables you to prevent...View answers
Questions : 23 :: What is Static Classes?
A static class is basically the same as a non-static class, but there is one difference: a static class cannot be instantiated.In other words, you cannot use the new keyword...View answers
Questions : 24 :: Explain Static Class Members.
A non-static class can contain static methods, fields, properties, or events.The static member is callable on a class even when no instance of the class has been created....View answers
Questions : 25 :: Which are Access Modifiers available in C#?
All types and type members have an accessibility level, which controls whether they can be used from other code in your assembly or other assemblies.You can use the...View answers
Questions : 26 :: Data Types in C#?
bool, byte, char, decimal, double, float, int, long, sbyte, short, uint, ulong, ushort.More question coming soon.. we are updating our list of ques and answer......View answers
Questions : 27 :: What are sealed classes in C#?
We create sealed classes when we want to restrict the class to be inherited. Sealed modifier used to prevent derivation from a class. If we forcefully specify a sealed class as base class...View answers
Questions : 28 :: What are delegates?
Delegates are same are function pointers in C++ but the only difference is that they are type safe unlike function pointers. Delegates are required because they can be used to write much...View answers
Questions : 29 :: What is the difference between a Struct and a Class?
Structs are value-type variables and classes are reference types. Structs stored on the stack, causes additional overhead but faster retrieval. Structs cannot be...View answers
Questions : 30 :: What is difference between is and as operators in c#?
“is” operator is used to check the compatibility of an object with a given type and it returns the result as Boolean.
“as” operator is used for casting of object to...View answers
Questions : 31 :: What are C# attributes and its significance?
C# provides developers a way to define declarative tags on certain entities eg. Class, method etc. are called attributes. The attribute’s information can be retrieved at runtime using...View answers
Questions : 32 :: What is a NullReferenceException and how do I fix it?
You are trying to use something that is null (or Nothing in VB.NET). This means you either set it to null, or you never set it to anything at all.
Like anything else, null gets passed around. If it...View answers
Questions : 33 :: How to update the GUI from another thread in C#?
Questions : 34 :: How to use reflection to call generic Method?
You need to use reflection to get the method to start with, then "construct" it by supplying type arguments with MakeGenericMethod:
MethodInfo method...View answers
Questions : 35 :: How to properly clean up Excel interop objects
Excel does not quit because your app is still holding references to COM objects.
I guess you're invoking at least one member of a COM object without assigning it to a variable.
For me it was the...View answers
Questions : 36 :: Why are mutable structs evil?
Structs are value types which means they are copied when they are passed around.
So if you change a copy you are changing only that copy, not the original and not any other copies which might be...View answers
Questions : 37 :: How do you convert Byte Array to Hexadecimal String, and vice versa?
public static string ByteArrayToString(byte[] ba){ StringBuilder hex = new StringBuilder(ba.Length * 2); foreach (byte b in ba) hex.AppendFormat("{0:x2}", b); ...View answers
Questions : 38 :: How do I calculate relative time?
const int SECOND = 1;const int MINUTE = 60 * SECOND;const int HOUR = 60 * MINUTE;const int DAY = 24 * HOUR;const int MONTH = 30 * DAY;var ts = new TimeSpan(DateTime.UtcNow.Ticks -...View answers
Questions : 39 :: What is the difference between a Field and a Property in C#?
Properties expose fields. Fields should (almost always) be kept private to a class and accessed via get and set properties. Properties provide a level of abstraction allowing you to change the fields...View answers
Questions : 40 :: Why is it important to override GetHashCode when Equals method is overridden?
Yes, it is important if your item will be used as a key in a dictionary, or HashSet<T>, etc - since this is used (in the absence of a custom IEqualityComparer<T>) to group items into...View answers
Questions : 41 :: How to force my .NET App to run as administrator on Windows 7?
You'll want to modify the manifest that gets embedded in the program. This works on VS2008 and higher: Project + Add New Item, select "Application Manifest File". Change the...View answers
Questions : 42 :: Top reason to use C# language?
Modern, general-purpose programming language Object oriented. Component oriented. Easy to learn. Structured language. It produces efficient programs. It can be compiled on a variety of computer...View answers
Questions : 43 :: Types of Constructors
Basically constructors are 5 types those are Default Constructor Parameterized Constructor Copy Constructor Static Constructor Private Constructor
Questions : 44 :: What is C#?
C# is an object oriented, type safe and managed language that is compiled by .Net framework to generate Microsoft Intermediate Language.
Questions : 45 :: Can multiple catch blocks be executed?
No, Multiple catch blocks can’t be executed. Once the proper catch code executed, the control is transferred to the finally block and then the code that follows the finally block gets...View answers
Questions : 46 :: What is the difference between public, static and void?
Public declared variables or methods are accessible anywhere in the application. Static declared variables or methods are globally accessible without creating an instance of the class. The compiler...View answers
Questions : 47 :: Define Constructors?
A constructor is a member function in a class that has the same name as its class. The constructor is automatically invoked whenever an object class is created. It constructs the values of data...View answers
Questions : 48 :: What is Jagged Arrays?
The array which has elements of type array is called jagged array. The elements can be of different dimensions and sizes. We can also call jagged array as Array of arrays.
Questions : 49 :: What is the difference between ref & out parameters?
An argument passed as ref must be initialized before passing to the method whereas out parameter needs not to be initialized before passing to a method.
Questions : 50 :: What is the use of using statement in C#?
The using block is used to obtain a resource and use it and then automatically dispose of when the execution of block completed.
Questions : 51 :: Can "this" be used within a static method?
We can’t use ‘This’ in a static method because we can only use static variables/methods in a static method.
Questions : 52 :: What is difference between constants and read-only?
Constant variables are declared and initialized at compile time. The value can’t be changed after wards. Read-only variables will be initialized only from the Static constructor of the class....View answers
Questions : 53 :: What is an interface class?
Interface is an abstract class which has only public abstract methods and the methods only have the declaration and not the definition. These abstract methods must be implemented in the inherited...View answers
Questions : 54 :: What are Custom Control and User Control?
Custom Controls are controls generated as compiled code (Dlls), those are easier to use and can be added to toolbox. Developers can drag and drop controls to their web forms. Attributes can be set at...View answers
Questions : 55 :: What is the difference between Array and Arraylist?
In an array, we can have items of the same type only. The size of the array is fixed. An arraylist is similar to an array but it doesn’t have a fixed size.
Questions : 56 :: What are the differences between System.String and System.Text.StringBuilder classes?
System.String is immutable. When we modify the value of a string variable then a new memory is allocated to the new value and the previous memory allocation released. System.StringBuilder was...View answers
Questions : 57 :: What's the difference between the System.Array.CopyTo() and System.Array.Clone() ?
Using Clone() method, we creates a new array object containing all the elements in the original array and using CopyTo() method, all the elements of existing array copies into another existing array....View answers
Questions : 58 :: How can we sort the elements of the array in descending order?
Using Sort() methods followed by Reverse() method.
Questions : 59 :: What's the difference between an interface and abstract class?
Interfaces have all the methods having only declaration but no definition. In an abstract class, we can have some concrete methods. In an interface class, all the methods are public. An abstract...View answers
Questions : 60 :: What is the difference between Finalize() and Dispose() methods?
Dispose() is called when we want for an object to release any unmanaged resources with them. On the other hand Finalize() is used for the same purpose but it doesn’t assure the garbage...View answers
Questions : 61 :: What are circular references?
Circular reference is situation in which two or more resources are interdependent on each other causes the lock condition and make the resources unusable.
Questions : 62 :: What are generics in C#.NET?
Generics are used to make reusable code classes to decrease the code redundancy, increase type safety and performance. Using generics, we can create collection classes. To create generic collection,...View answers
Questions : 63 :: What is an object pool in .NET?
An object pool is a container having objects ready to be used. It tracks the object that is currently in use, total number of objects in the pool. This reduces the overhead of creating and...View answers
Questions : 64 :: List down the commonly used types of exceptions in .Net?
Sometimes there are some errors that need to be handeled as per user requirements. Custom exceptions are used for them and are used defined exceptions.
Questions : 66 :: How do you inherit a class into other class in C#?
Colon is used as inheritance operator in C#. Just place a colon and then the class...View answers
Questions : 67 :: What is the difference between method overriding and method overloading?
In method overriding, we change the method definition in the derived class that changes the method behavior. Method overloading is creating a method with the same name within the same class having...View answers
Questions : 68 :: What are the different ways a method can be overloaded?
Methods can be overloaded using different data types for parameter, different order of parameters, and different number of parameters.
Questions : 69 :: Why can't you specify the accessibility modifier for methods inside the interface?
In an interface, we have virtual methods that do not have method definition. All the methods are there to be overridden in the derived class. That’s why they all are public.
Questions : 70 :: How can we set class to be inherited, but prevent the method from being over-ridden?
Declare the class as public and make the method sealed to prevent it from being overridden.
Questions : 71 :: What happens if the inherited interfaces have conflicting method names?
Implement is up to you as the method is inside your own class. There might be problem when the methods from different interfaces expect different data, but as far as compiler cares you’re...View answers
Questions : 72 :: How to implement singleton design pattern in C#?
In singleton pattern, a class can only have one instance and provides access point to it globally.
Eg:{
private static readonly singleton _instance=new singleton();
}
Questions : 73 :: What is the difference between directcast and ctype?
DirectCast is used to convert the type of an object that requires the run-time type to be the same as the specified type in DirectCast.
Ctype is used for conversion where the conversion is defined...View answers
Questions : 74 :: Is C# code is managed or unmanaged code?
C# is managed code because Common language runtime can compile C# code to Intermediate language.
Questions : 75 :: Famous Insurance company has a requirement to calculate the age of their customer based on the date of birth received as a string from the user.
Write a program that receives the customer date of birth in the format (dd-mm-yyyy).
Pass this value to a method, 'calculateAge' which returns the calculated age. Keep the method 'static'.
Method to implement:
public static int calculateAge(string dateOfBirth)
Sample Input :
Enter the date of birth (dd-mm-yyyy): 22-10-1984
Sample Output:
36
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;public class Person{ DateTime dob; public DateTime Dob { get{return dob;}...View answers
Questions : 76 :: C SHARP IN GAMING?
C# is widely-used to create games using the Unity game engine, which is the most popular game engine today. More than a third of top games are made with Unity, and there are approximately 770...View answers
Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website.
If you are using this website then its your own responsibility to understand the content of the website