|
|
|
|
|
Winforms Interview Questions / FAQs |
|
|
| How can I get a list of all processes running on my system? |
| Use the static Process.GetProcesses() found in the System.Diagnostics namespace.
Using System.Diagnostics;
...
foreach ( Process p in Process.GetProcesses() )
Console.WriteLine( p ); // string s = p.ToString(); |
|
|
|
|
|
| Can you write a class without specifying namespace? Which namespace does it belong to by default? |
| Yes, you can. Then the class belongs to global namespace which has no name. For commercial products, naturally, you would not want global namespace. |
|
|
|
|
|
| How do I prevent the beep when the user presses the Enter key in a TextBox? |
| You can prevent the beep when the enter key is pressed in a TextBox by deriving the TextBox and overriding OnKeyPress -
public class CustomTextBox : TextBox {
protected override void OnKeyPress( KeyPressEventArgs e )
{
if ( e.KeyChar == (char) 13 )
e.Handled = true;
else
base.OnKeyPress( e );
} } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|