Walkins Openings in India & Interview Questions

Walkins in Mumbai, Bangalore, Chennai, Delhi, Gurgaon, Pune


‘C# Interview Questions’ - KyaPoocha.com

What optimizations does the C# compiler perform when you use the /optimize+ compiler option? 

The following is a response from a developer on the C# compiler team: We get rid of unused locals (i.e., locals that are never read, even if assigned). We get rid... Read more »

Is there an equivalent of exit() for quitting a C# .NET application? 

Yes, you can use System.Environment.Exit(int exitCode) to exit the application or Application.Exit() if it’s a Windows Forms app.  Read more »

Is it possible to restrict the scope of a field/method of a class to the classes in the same namespace? 

There is no way to restrict to a namespace. Namespaces are never units of protection. But if you’re using assemblies, you can use the ‘internal’ access modifier... Read more »

Is it possible to have different access modifiers on the get/set methods of a property? 

No. The access modifier on a property applies to both its get and set accessors. What you need to do if you want them to be different is make the property read-only... Read more »

How does one compare strings in C#? 

In the past, you had to call .ToString() on the strings when using the == or != operators to compare the strings’ values. That will still work, but the C# compiler... Read more »

How do you mark a method obsolete? 

[Obsolete] public int Foo() {…} or [Obsolete(\”This is a message describing why this method is obsolete\”)] public int Foo() {…} Note: The O in Obsolete... Read more »

Does C# have its own class library? 

Not exactly. The .NET Framework has a comprehensive class library, which C# can make use of. C# does not have its own class library.  Read more »

What standard types does C# use? 

C# supports a very similar range of basic types to C++, including int, long, float, double, char, string, arrays, structs and classes. However, don’t assume too... Read more »

What are the fundamental differences between value types and reference types? 

C# divides types into two categories - value types and reference types. Most of the intrinsic types (e.g. int, char) are value types. Structs are also value types.... Read more »

Structs are largely redundant in C++. Why does C# have them? 

In C++, a struct and a class are pretty much the same thing. The only difference is the default visibility level (public for structs, private for classes). However,... Read more »

Are C# constructors the same as C++ constructors? 

Very similar, but there are some significant differences. First, C# supports constructor chaining. This means one constructor can call another: class Person { public... Read more »

Are C# destructors the same as C++ destructors? 

No. They look the same but they are very different. The C# destructor syntax (with the familiar ~ character) is just syntactic sugar for an override of the System.Object... Read more »

Are all methods virtual in C#? 

No. Like C++, methods are non-virtual by default, but can be marked as virtual.  Read more »

How do I declare a pure virtual function in C#? 

Use the abstract modifier on the method. The class must also be marked as abstract (naturally). Note that abstract methods cannot have an implementation (unlike... Read more »

Can I call a virtual method from a constructor/destructor? 

Yes, but it’s generally not a good idea. The mechanics of object construction in .NET are quite different from C++, and this affects virtual method calls in constructors. C++... Read more »

Should I make my destructor virtual? 

A C# destructor is really just an override of the System.Object Finalize method, and so is virtual by definition.  Read more »

Can I use exceptions in C#? 

Yes, in fact exceptions are the recommended error-handling mechanism in C# (and in .NET in general). Most of the .NET framework classes use exceptions to signal... Read more »

What types of object can I throw as exceptions? 

Only instances of the System.Exception classes, or classes derived from System.Exception. This is in sharp contrast with C++ where instances of almost any type can... Read more »

When should I throw an exception? 

This is the subject of some debate, and is partly a matter of taste. However, it is accepted by many that exceptions should be thrown only when an ‘unexpected’... Read more »

Does C# support a variable number of arguments? 

Yes, using the params keyword. The arguments are specified as a list of arguments of a specific type, e.g. int. For ultimate flexibility, the type can be object.... Read more »

Page 4 of 5«12345»
  • Subscribe

      Get Latest Walkins in your INBOX, enter your email address:


  • Walkins by Location


  • Walkins by Skills