You have added a button named Bt1 to your form, whose Text is “Go”. You want to assign a shortcut to the button, so that whenever a user presses ALT+G, the Click event of the button Bt1 is raised. What code should you use?

  1. Bt1.Text = @”Go”;

  2. Bt1.Text = “&Go”;

  3. Bt1.Text = “&&Go”;

  4. Bt1.Text = “@Go”;


Correct Option: B

AI Explanation

To assign a shortcut to the button Bt1 so that the Click event is raised when the user presses ALT+G, you need to use the '&' character in the button's text. This character is used to define the shortcut key.

The correct code to assign the shortcut would be:

Bt1.Text = "&Go";

Option A) Bt1.Text = @”Go”; - This option is incorrect because it does not include the '&' character to define the shortcut key.

Option B) Bt1.Text = “&Go”; - This option is correct because it includes the '&' character to define the shortcut key as ALT+G.

Option C) Bt1.Text = “&&Go”; - This option is incorrect because it includes two '&' characters, which is not necessary and would not work as a shortcut key.

Option D) Bt1.Text = “@Go”; - This option is incorrect because it includes the '@' character, which is not used to define a shortcut key.

The correct answer is Option B.

Find more quizzes: