C# (Sharp) Programming Language

  Home  Microsoft .Net Technologies  C# (Sharp) Programming Language


“Learn C# (Sharp) Programming Language by Interview Questions and Answers”



163 C# (Sharp) Programming Language Questions And Answers

124⟩ Is there a way of specifying which block or loop to break out of when working with nested loops?

The easiest way is to use goto: using System;

class BreakExample

{

public static void Main(String[] args)

{

for(int i=0; i<3; i++)

{

Console.WriteLine("Pass {0}: ", i);

for( int j=0 ; j<100 ; j++ )

{

if ( j == 10) goto done;

Console.WriteLine("{0} ", j);

}

Console.WriteLine("This will not print");

}

done:

Console.WriteLine("Loops complete.");

}

}

 233 views

127⟩ 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

 207 views

130⟩ 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.

 204 views

131⟩ 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();

}

}

 212 views

136⟩ Does C# support templates?

No. However, there are plans for C# to support a type of template known as a generic. These generic types have similar syntax but are instantiated at run time as opposed to compile time. You can read more about them here.

 204 views