Appian Corporation C# Interview Questions Answers

Why Would You Use Untrusted Verification?

Web Services might use it, as well as non-Windows applications.

What Is The Implicit Name Of The Parameter That Gets Passed Into The Class Set Method?

Value, and its datatype depends on whatever variable we are changing.

How Do I Register My Code For Use By Classic Com Clients?

Use the regasm.exe utility to generate a type library (if needed) and the necessary entries in the Windows Registry to make a class available to classic COM clients. Once a class is registered in the Windows Registry with regasm.exe, a COM client can use the class as though it were a COM class.

How Do I Do Implement A Trace And Assert?

Use a conditional attribute on the method, as shown below
class Debug
{
[conditional("TRACE")]
public void Trace(string s)
{
Console.WriteLine(s);
}
}
class MyClass
{
public static void Main()
{
Debug.Trace("hello");
}
}

In this example, the call to Debug.Trace() is made only if the preprocessor symbol TRACE is defined at the call site. You can define preprocessor symbols on the command line by using the /D switch. The restriction on conditional methods is that they must have void return type.

How Can You Create A Strong Name For A .net Assembly?

With the help of Strong Name tool (sn.exe).

Where's Global Assembly Cache Located On The System?

Usually C:\winnt\assembly or C:\windows\assembly.

Can You Have Two Files With The Same File Name In Gac?

Yes, remember that GAC is a very special folder, and while normally you would not be able to place two files with the same name into a Windows folder, GAC differentiates by version number as well, so it’s possible for MyApp.dll and MyApp.dll to co-exist in GAC if the first one is version 1.0.0.0 and the second one is 1.1.0.0.

So Let's Say I Have An Application That Uses Myapp.dll Assembly, Version 1.0.0.0. There Is A Security Bug In That Assembly, And I Publish The Patch, Issuing It Under Name Myapp.dll 1.1.0.0. How Do I Tell The Client Applications That Are Already Installed To Start Using This New Myapp.dll?

Use publisher policy. To configure a publisher policy, use the publisher policy configuration file, which uses a format similar app .config file. But unlike the app .config file, a publisher policy file needs to be compiled into an assembly and placed in the GAC.

What Is Delay Signing?

Delay signing allows you to place a shared assembly in the GAC by signing the assembly with just the public key. This allows the assembly to be signed with the private key at a later stage, when the development process is complete and the component or assembly is ready to be deployed. This process enables developers to work with shared assemblies as if they were strongly named, and it secures the private key of the signature from being accessed at different stages of development.
Appian Corporation Most Frequently Asked Latest C# Interview Questions Answers
Appian Corporation Most Frequently Asked Latest C# Interview Questions Answers

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.

Can You Prevent Your Class From Being Inherited And Becoming A Base Class For Some Other Classes?

Yes, that is what keyword sealed in the class definition is for. The developer trying to derive from your class will get a message: cannot inherit from Sealed class WhateverBaseClassName. It is the same concept as final class in Java.

If A Base Class Has A Bunch Of Overloaded Constructors, And An Inherited Class Has Another Bunch Of Overloaded Constructors, Can You Enforce A Call From An Inherited Constructor To An Arbitrary Base Constructor?

Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.

I Was Trying To Use An "out Int" Parameter In One Of My Functions. How Should I Declare The Variable That I Am Passing To It?

You should declare the variable as an int, but when you pass it in you must specify it as 'out', like the following
int i;
foo(out i);
where foo is declared as follows
[return-type] foo(out int o) { }

How Do I Make A Dll In C#?

You need to use the /target:library compiler option.

What Is The C# Equivalent Of C++ Catch (....), Which Was A Catch-all Statement For Any Possible Exception? Does C# Support Try-catch-finally Blocks?

Yes. Try-catch-finally blocks are supported by the C# compiler. Here's an example of a try-catch-finally block
using System;
public class TryTest
{
static void Main()
{
try
{
Console.WriteLine("In Try block");
throw new ArgumentException();
}
catch(ArgumentException n1)
{
Console.WriteLine("Catch Block");
}
finally
{
Console.WriteLine("Finally Block");
}
}
}
Output: In Try Block
Catch Block
Finally Block

If I return out of a try/finally in C#, does the code in the finally-clause run? Yes. The code in the finally always runs. If you return out of the try block, or even if you do a "goto" out of the try, the finally block always runs, as shown in the following example
using System;
class main
{
public static void Main()
{
try
{
Console.WriteLine("In Try block");
return;
}
finally
{
Console.WriteLine("In Finally block");
}
}
}

Both "In Try block" and "In Finally block" will be displayed. Whether the return is in the try block or after the try-finally block, performance is not affected either way. The compiler treats it as if the return were outside the try block anyway. If it's a return without an expression (as it is above), the IL emitted is identical whether the return is inside or outside of the try. If the return has an expression, there's an extra store/load of the value of the expression (since it has to be computed within the try block).

How Do I Create A Multi Language, Multi File Assembly?

Unfortunately, this is currently not supported in the IDE. To do this from the command line, you must compile your projects into netmodules (/target:module on the C# compiler), and then use the command line tool al.exe (alink) to link these netmodules together.

C# Provides A Default Constructor For Me. I Write A Constructor That Takes A String As A Parameter, But Want To Keep The No Parameter One. How Many Constructors Should I Write?

Two. Once you write at least one constructor, C# cancels the freebie constructor, and now you have to write one yourself, even if there is no implementation in.

What Is The Equivalent To Regsvr32 And Regsvr32 /u A File In .net Development?

Try using RegAsm.exe. The general syntax would be: RegAsm. A good description of RegAsm and its associated switches is located in the .NET SDK docs. Just search on "Assembly Registration Tool".Explain ACID rule of thumb for transactions.

Transaction must be Atomic (it is one unit of work and does not dependent on previous and following transactions), Consistent (data is either committed or roll back, no in-between case where something has been updated and something hasnot), Isolated (no transaction sees the intermediate results of the current transaction), Durable (the values persist if the data had been committed even if the system crashes right after).

How Do I Create A Multilanguage, Single-file Assembly?

This is currently not supported by Visual Studio .NET.

Why Cannot You Specify The Accessibility Modifier For Methods Inside The Interface?

They all must be public. Therefore, to prevent you from getting the false impression that you have any freedom of choice, you are not allowed to specify any accessibility, it is public by default.

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 to restrict access to only within the assembly.

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.

What Is The Advantage Of Using System.text.stringbuilder Over System.string?

StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are im mutable , so each time it is being operated on, a new instance is created.

Why Do I Get A Security Exception When I Try To Run My C# App?

Some security exceptions are thrown if you are working on a network share. There are some parts of the frameworks that will not run if being run off a share (roaming profile, mapped drives, etc.). To see if this is what's happening, just move the executable over to your local drive and see if it runs without the exceptions. One of the common exceptions thrown under these conditions is System.Security.SecurityException.

To get around this, you can change your security policy for the intranet zone, code group 1.2, (the zone that running off shared folders falls into) by using the caspol.exe tool.

Is There Any Sample C# Code For Simple Threading?

Some sample code follows: using System;
using System.Threading;
class ThreadTest
{
public void runme()
{
Console.WriteLine("Runme Called");
}
public static void Main(String[] args)
{
ThreadTest b = new ThreadTest();
Thread t = new Thread(new ThreadStart(b.runme));
t.Start();
}
}

What Is The Difference Between // Comments, /* */ Comments And /// Comments?

Single-line, multi-line and XML documentation comments.

How Do You Inherit From A Class In C#?

Place a colon and then the name of the base class. Notice that it is double colon in C++.

Post a Comment

Previous Post Next Post