October 16, 2018

Srikaanth

Kofax Most Frequently Asked Latest C# Interview Questions Answers


What Is The Wildcard Character In Sql?

Let’s say you want to query database with LIKE for all employees whose name starts with La. The wildcard character is %, the proper query with LIKE would involve ‘La%’.

Between Windows Authentication And Sql Server Authentication, Which One Is Trusted And Which One Is Untrusted?

Windows Authentication is trusted because the username and password are checked with the Active Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction.

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).

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 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 now automatically compares the values instead of the references when the == or != operators are used on string types. If you actually do want to compare references, it can be done as follows: if ((object) str1 == (object) str2) { } Here’s an example showing how string compares work
using System;
public class StringTest
{
public static void Main(string[] args)
{
Object nullObj = null; Object realObj = new StringTest();
int i = 10;
Console.WriteLine(\"Null Object is [\" + nullObj + \"]\n\" + \"Real Object is [\" + realObj + \"]\n\" + \"i is [\" + i + \"]\n\");
// Show string equality operators
string str1 = \"foo\";
string str2 = \"bar\";
string str3 = \"bar\";
Console.WriteLine(\"{0} == {1} ? {2}\", str1, str2, str1 == str2 );
Console.WriteLine(\"{0} == {1} ? {2}\", str2, str3, str2 == str3 );
}
}

Output
Null Object is []
Real Object is [StringTest]
i is [10]
foo == bar ? False
bar == bar ? True
Kofax Most Frequently Asked Latest C# Interview Questions Answers
Kofax Most Frequently Asked Latest C# Interview Questions Answers

How Do You Specify A Custom Attribute For The Entire Assembly (rather Than For A Class)?

Global attributes must appear after any top-level using clauses and before the first type or namespace declarations. An example of this is as follows
using System;
[assembly : MyAttributeClass] class X {}
Note that in an IDE-created project, by convention, these attributes are placed in AssemblyInfo.cs.

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 is always capitalized.

How Do You Implement Thread Synchronization (object.wait, Notify,and Criticalsection) In C#?

You want the lock statement, which is the same as Monitor Enter/Exit
lock(obj) { // code }
translates to
try {
CriticalSection.Enter(obj);
// code
}
finally
{
CriticalSection.Exit(obj);
}

How Do You Directly Call A Native Function Exported From A Dll?

Here’s a quick example of the DllImport attribute in action

using System.Runtime.InteropServices;
class C
{
[DllImport(\"user32.dll\")]
public static extern int MessageBoxA(int h, string m, string c, int type);
public static int Main()
{
return MessageBoxA(0, \"Hello World!\", \"Caption\", 0);
}
}

This example shows the minimum requirements for declaring a C# method that is implemented in a native DLL. The method C.MessageBoxA() is declared with the static and external modifiers, and has the DllImport attribute, which tells the compiler that the implementation comes from the user32.dll, using the default name of Message BoxA. For more information, look at the Platform Invoke tutorial in the documentation.

How Do I Simulate Optional Parameters To Com Calls?

You must use the Missing class and pass Missing.Value (in System.Reflection) for any values that have optional parameters.

What Do You Know About .net Assemblies?

Assemblies are the smallest units of versioning and deployment in the .NET application. Assemblies are also the building blocks for programs such as Web services, Windows services, serviced components, and .NET remoting applications.

What's The Difference Between Private And Shared Assembly?

Private assembly is used inside an application only and does not have to be identified by a strong name. Shared assembly can be used by multiple applications and has to have a strong name.

What's A Strong Name?

A strong name includes the name of the assembly, version number, culture identity, and a public key token.

How Can You Tell The Application To Look For Assemblies At The Locations Other Than Its Own Install?

Use the directive in the XML .config file for a given application.
< probing privatePath=c:\mylibs; bin\debug />
should do the trick. Or you can add additional search paths in the Properties box of the deployed application.

How Can You Debug Failed Assembly Binds?

Use the Assembly Binding Log Viewer (fuslogvw.exe) to find out the paths searched.

Where Are Shared Assemblies Stored?

Global assembly cache.

Is There Regular Expression (regex) Support Available To C# Developers?

Yes. The .NET class libraries provide support for regular expressions. Look at the documentation for the System. Text.Regular Expressions namespace.

Is There A Way To Force Garbage Collection?

Yes. Set all references to null and then call System.GC.Collect(). If you need to have some objects destructed, and System.GC.Collect() doesn't seem to be doing it for you, you can force finalizers to be run by setting all the references to the object to null and then calling System.GC.RunFinalizers().

Does C# Support Properties Of Array Types?

Yes. Here's a simple example
using System;
class Class1
{
private string[] MyField;
public string[] MyProperty
{
get { return MyField; }
set { MyField = value; }
}
}
class MainClass
{
public static int Main(string[] args)
{
Class1 c = new Class1();
string[] arr = new string[] {"apple", "banana"};
c.MyProperty = arr;
Console.WriteLine(c.MyProperty[0]); // "apple"
return 0;
}
}

How Is Method Overriding Different From Overloading?

When overriding, you change the method behavior for a derived class. Overloading simply involves having a method with the same name within the class.

Subscribe to get more Posts :