-
How do I convert a string to an int in C#?
Here's an example: using System;class StringToInt{public static void Main(){String s = "105";int x = Convert.ToInt32(s);Console.WriteLine(x);}}
-
How do destructors and garbage collection work in C#?
C# has finalizers (similar to destructors except that the runtime doesn't guarantee they'll be called), and they are specified as follows: class C{~C(){// your code}public static void Main() {}}Currently, they override object.Finalize(), which is called during the GC process.
-
Why do I get a syntax error when trying to declare a variable called checked?
The word checked is a keyword in C#.
-
Does Console.WriteLine() stop printing when it reaches a NULL character within a string?
Strings are not null terminated in the runtime, so embedded nulls are allowed. Console.WriteLine() and all similar methods continue until the end of the string.
-
Garbage Collector:
Skill/Topic: AdvancedA) Copies the IL code to the heapB) Destroys the pointersC) is responsible for automatic memory management
-
Method Overloading and Overriding are the same
Skill/Topic: IntermediateA) TrueB) FalseExplanation: Overloading is changing the behavior of a method in a derived class, whereas overriding is having multiple methods with the same name
-
What is similar in concept to IL?
Skill/Topic: IntermediateA) Java Byte CodeB) C++ LibrariesC) Machine Language
-
Is there an equivalent to the instanceof operator in Visual J++?
C# has the is operator: expr is type
-
If you need your own implementation of Equals method of object what needs to be done
A) Overload Equals methodB) Override Equals methodC) Implements Equals method
-
Which statement is invalid with regards to Constant
A) They must be initialized when they are declaredB) The value of the constant must be computable at compile timeC) Constants are not staticD) Constant is a variable whose value can be changed through out it’s life time when it is static.
-
Which of the member is not a member of Object
A) Equals ( )B) GetType ( )C) ToString ( )D) Parse( )
-
Write a class in C# which get an action in its construction
Write a class in C# which get an action (parameter less delegate) in its construction and has a single public method ‘bool execute()’ which does following: 1. Execute the action only if no other thread is currently executing the action.2. If another thread is already executing, wait until thread finished before returning (but without executing action again)3. Return true if current thread that action,...
-
Use C# to turn on the 4th and 7th bits
Use C# to turn on the 4th and 7th bits of a said byte myFlag, in which right most bit is first bit.Answer[Flags] enum BitFlags : byte { One = (1
-
Which of the following is not a C# reserved keyword
A) IsB) AsC) InD) Of
-
Which of the following can not be declared as virtual
A) Static functionsB) Member fieldsC) Instance functions
-
Sealed class can be inherited
A) TrueB) FalseExplanation: Sealed class cannot be inherited
-
What is the difference between a struct and a class in C#?
From language spec:The list of similarities between classes and structs is as follows. Longstructs can implement interfaces and can have the same kinds of members as classes. Structs differ from classes in several important ways; however, structs are value types rather than reference types, and inheritance is not supported for structs. Struct values are stored on the stack or in-line. Careful programmers...
-
-
Interface members can not be declared as
A) VirtualB) StaticC) PrivateD) All of the above
-
Which method is implicitly called when an object is created
A) Main MethodB) Constructor MethodC) Destructor MethodExplanation: Constructor is the method which is implicitly created when ever a class is instantiated
C# Interview Questions
Ans